Home >Backend Development >PHP Tutorial >php function array_pop to delete the last element in the array
php array_pop function pops (pops) the last unit of the array, that is, deletes the last element of the array. This article explains how to use the array_pop function through PHP examples.
array_pop — pop the last unit of the array (pop off the stack)
mixed array_pop (array &$array)
array_pop() pops and returns the array array last element and decrements the length of the array by one. NULL will be returned if array is empty (or not an array). In addition, a Warning will be generated if the called value is not a number.
Note: The array pointer will be reset (reset()) after using this function.
Delete the last element in the array:
<?php $a=array("red","green","blue"); array_pop($a); print_r($a); ?>
Definition and usage
array_pop() function deletes the last element in the array.
Syntax
array_pop(array)
Parameters Description
##array Required. Specifies an array.//实例 //删除数组中的最后一个元素: <?php $a=array("red","green","blue"); array_pop($a); print_r($a); ?> 运行实例 » 定义和用法 array_pop() 函数删除数组中的最后一个元素。 语法 array_pop(array) 参数描述 array 必需。规定数组。
The above is the detailed content of php function array_pop to delete the last element in the array. For more information, please follow other related articles on the PHP Chinese website!