Latest web development tutorials

PHP array_pop () function

PHP Array Reference Complete PHP Array Reference

Examples

Remove the last element in the array:

<?php
$a=array("red","green","blue");
array_pop($a);
print_r($a);
?>

Running instance »

Definition and Usage

array_pop () function removes the last element in the array.


grammar

array_pop( array )

参数 描述
array 必需。规定数组。

technical details

return value: It returns the last value of the array. If the array is empty or is not an array, it returns NULL.
PHP version: 4+


PHP Array Reference Complete PHP Array Reference