How to delete the last array element in php: You can use the built-in function array_pop() to delete. The array_pop() function can delete the last element in the specified array and will return null if the array is empty or not an array.
array_pop() function removes the last element in the array and returns the last value of the array. If the array is empty, or is not an array, NULL will be returned.
(Recommended tutorial: php graphic tutorial)
Grammar:
array_pop(array)
(Recommended learning video: php video tutorial )
Implementation code:
<?php $a=array("red","green","blue"); array_pop($a); print_r($a); ?>
Output result:
Array ( [0] => red [1] => green )
The above is the detailed content of How to delete the last array element in php. For more information, please follow other related articles on the PHP Chinese website!