Usage of array_pop function in php: [array_pop(array)]. The array_pop function is used to delete the last element in the array and return the last value in the array; if the array is empty or not an array, it returns null.
php The array_pop function is used to delete the last element in the array. Its syntax is array_pop(array). The parameter array is required and specifies the array.
(Recommended tutorial: php video tutorial)
How to use the php array_pop function?
Function: Delete the last element in the array
Syntax:
array_pop(array)
Parameters:
array required. Specifies an array.
Description:
Returns the last value of the array. If the array is empty, or not an array, NULL will be returned.
php array_pop() function usage example 1
<?php $a=array("西门","灭绝"); print_r(array_pop($a)); // 打印被删除的元素 echo "<br>"; print_r($a); //打印处理之后的数组 ?>
Output:
灭绝 Array ( [0] => 西门 )
php array_pop() function usage example 2
<?php $a=array("无忌","欧阳克","peter_zhu"); print_r(array_pop($a)); // 打印被删除的元素 echo "<br>"; print_r($a); //打印处理之后的数组 ?>
Output:
peter_zhu Array ( [0] => 无忌 [1] => 欧阳克 )
The above is the detailed content of How to use array_pop function in php. For more information, please follow other related articles on the PHP Chinese website!