PHP array_pop()函数 (PHP array_pop() function)
array_pop() function is used to delete/pop last element from the array.
array_pop()函数用于从数组中删除/弹出最后一个元素。
Syntax:
句法:
array_pop(array);
Here, array is the input array, function will delete last element from it.
在这里, array是输入数组,函数将从其中删除最后一个元素。
Examples:
例子:
Input:
//initial array is
$arr = array(100, 200, 300, 10, 20, 500);
//deleting elements
array_pop($arr);
array_pop($arr);
array_pop($arr);
Output:
Array
(
[0] => 100
[1] => 200
[2] => 300
)
PHP code to delete elements from an array using array_pop() function
PHP代码使用array_pop()函数从数组中删除元素
<?php
$arr = array(100, 200, 300, 10, 20, 500);
array_pop($arr);
array_pop($arr);
array_pop($arr);
print("array after removing elements...\n");
print_r($arr);
?>
Output
输出量
array after removing elements...
Array
(
[0] => 100
[1] => 200
[2] => 300
)
翻译自: https://www.includehelp.com/php/array_pop-function-with-example.aspx