2 ways to get the last value of an array in PHP, 2 ways for arrays
Copy code The code is as follows:
$array=array(1,2,3,4,5);
echo $array[count($array)-1];//Calculate the length of the array, and then get the last element of the array. If the last element in the array contains a non-numeric key name, the result may not be as expected
//Applicable to arrays with key names
echo '
';
echo end($array);//Point the internal pointer of the array to the last unit, applicable to all arrays
http://www.bkjia.com/PHPjc/945711.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/945711.htmlTechArticlePHP has two methods to get the last value of an array. The two types of array copy code are as follows: $array=array( 1,2,3,4,5); echo $array[count($array)-1];//Calculate the length of the array, and then get the maximum length of the array...