(PHP 4, PHP 5)
array_pop — 将数组最后一个单元弹出(出栈)
array_pop() 弹出并返回
array
数组的最后一个单元,并将数组
array
的长度减一。如果
array
为空(或者不是数组)将返回 NULL
。
Example #1 array_pop() 例子
<?php
$stack = array("orange", "banana", "apple", "raspberry");
$fruit = array_pop($stack);
print_r($stack);
?>
经过此操作后,$stack 将只有 3 个单元:
Array ( [0] => orange [1] => banana [2] => apple )
并且 rasberry 将被赋给 $fruit。
array
The array to get the value from.
Returns the last value of array
.
If array
is empty (or is not an array),
NULL
will be returned.
Example #2 array_pop() example
<?php
$stack = array("orange", "banana", "apple", "raspberry");
$fruit = array_pop($stack);
print_r($stack);
?>
After this, $stack will have only 3 elements:
Array ( [0] => orange [1] => banana [2] => apple )
and raspberry will be assigned to $fruit.