PHP array_pop function
The PHP function array_pop removes the last element from an array and returns the removed element.
whileto iterate through the array, this is something to keep in mind.
array_pop(array &$array): mixedSintaxis / Sintax
$value_poped = array_pop($array);
Before proceeding, note in the description that the array is passed by reference,
&$array, and therefore, the original array will be changed.
&$array – The array from which the last element will be removed, passing the value of the removed element as the return.
mixed – Returns the value of the removed element from the array.
null – in case the array is empty.
PHP array_pop example
We will only do an example of
array_pop since it is a function that performs a very specific action
$stack = array("orange", "banana", "apple", "raspberry"); $fruit = array_pop($stack); echo "valor eliminado: $fruit\n"; print_r($stack);