array_pop in PHP

Syntax of array_pop in PHP

mixed array_pop(array &stack)

Removes the last value from the given array and returns it. If the array is empty (or the argument is not an array), returns NULL. Note that the array pointer is reset on the provided

$stack = array("orange", "banana", "apple", "raspberry");
$fruit = array_pop($stack);
    [0] => orange
    [1] => banana
    [2] => apple

Leave a Comment