PHP | Ds\Vector pop()函数
Ds\Vector::pop()函数是PHP中的一个内置函数,用于删除向量的最后一个元素并返回它。
句法:
mixed public Ds\Vector::pop( void )
参数:此函数不接受任何参数。
返回值:此函数返回从向量中删除的最后一个元素。
下面的程序说明了PHP中的Ds\Vector::pop()函数:
方案一:
pop());
echo("\nVector after removing the last element\n");
print_r($arr1);
?>
输出:
Original vector elements
Ds\Vector Object
(
[0] => 10
[1] => 20
[2] => 30
[3] => 40
[4] => 50
)
Last element in vector: int(50)
Vector after removing the last element
Ds\Vector Object
(
[0] => 10
[1] => 20
[2] => 30
[3] => 40
)
方案二:
pop());
echo("\nVector after removing the last element\n");
print_r($arr1);
?>
输出:
Original vector elements
Ds\Vector Object
(
[0] => geeks
[1] => for
[2] => geeks
)
Last element in vector: string(5) "geeks"
Vector after removing the last element
Ds\Vector Object
(
[0] => geeks
[1] => for
)
参考: http: PHP。 PHP