Removes and returns one element off the end of an array.
array_pop() removes an element off the end of an array. The removed element is returned.
An array can be used as a stack by using array_push() and array_pop() together.
<?php
$array1 = array("one", "two", "three");
foreach ($array1 as $element)
print "$element ";
print "<br>" . array_pop($array1) . "<br>";
foreach ($array1 as $element)
print "$element ";
?>
one two three
three
one two
This code shows the results of popping an array.