PHP | Ds\Deque pop()函数
Ds\Deque::pop()函数是PHP中的一个内置函数,用于从 Deque 中删除最后一个元素(如果 Deque 不为空)并返回它。如果 Deque 为空,则会引发异常。
句法:
public Ds\Deque::pop( void ) : mixed
参数:此函数不接受任何参数。
返回值:此函数返回从 Deque 中删除的最后一个元素。
下面的程序说明了PHP中的Ds\Deque::pop()函数:
方案一:
pop());
echo("\nElements of Deque\n");
// Display the Deque elements
print_r($deck);
?>
输出:
Elements of Deque
Ds\Deque Object
(
[0] => 10
[1] => 20
[2] => 30
[3] => 40
[4] => 50
[5] => 60
)
Last element of deque: 60
Elements of Deque
Ds\Deque Object
(
[0] => 10
[1] => 20
[2] => 30
[3] => 40
[4] => 50
)
方案二:
pop());
echo("\nElements of Deque\n");
// Display the Deque elements
print_r($deck);
?>
输出:
Elements of Deque
Ds\Deque Object
(
[0] => geeks
[1] => for
[2] => geeks
[3] => practice
)
Last element of deque: practice
Elements of Deque
Ds\Deque Object
(
[0] => geeks
[1] => for
[2] => geeks
)
参考: http: PHP。 PHP