array_pop

PHP 4, PHP 5, PHP 7, PHP 8
array_pop - Pop the element off the end of array

array_pop( arrayarray ): mixed

array_pop pops and returns the value of the last element of array, shortening the array by one element.

Note:

This function will reset the array pointer of the input array after use.

Parameters

array

The array to get the value from.

Return Values

Returns the value of the last element of array. If array is empty (or is not an array), null will be returned.

Exceptions and Errors

This function will produce an error of level E_WARNING when called on a non-array.

Related Functions

Example of array_pop

Show all examples for array_pop

PHP Version:


Function array_pop:

Arrays Functions

Most used PHP functions