Home >php教程 >php手册 >PHP array_pop() 函数

PHP array_pop() 函数

WBOY
WBOYOriginal
2016-06-21 08:52:381492browse

定义和用法
array_pop() 函数删除数组中的最后一个元素。
语法
array_pop(array)
参数     描述
array     必需。规定输入的数组参数。
例子
$arr = array(
'asp',
'php',
'jsp',
'.net',
'c++'
);

echo '原数组:';
echo '

';<br>
print_r($arr);<br>
echo '
';

$arr_tmp = array_pop($arr);
echo '
';

echo '
';<br>
echo 'pop出数组的元素是:<b>'.$arr_tmp .'</b>';<br>
echo '<br>';<br>
<br>
echo '调用函数array_pop()之后:';<br>
print_r($arr);<br>
?><br>
<br>
<strong>输出:</strong><br>
原数组:Array<br>
(<br>
    [0] => asp<br>
    [1] => php<br>
    [2] => jsp<br>
    [3] => .net<br>
    [4] => c++<br>
)<br>
pop出数组的元素是:c++<br>
调用函数array_pop()之后:Array<br>
(<br>
    [0] => asp<br>
    [1] => php<br>
    [2] => jsp<br>
    [3] => .net<br>
)
            <p style="width:100%;text-align:center;margin:10px 0">

<br>
<br>

</p><p style="width:100%;text-align:center;margin:10px 0">

            </p><p class="clear"></p>

           
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn