怎样才能删除数组的最后一个元素?_PHP教程
时间:2021-07-01 10:21:17
帮助过:37人阅读
用PHP4中带的array_pop这个函数即可,函数原型:
mixed array_pop(array array)
举个例子:
$array = array('PHP','JSP','ASP');
$count = count($array);
echo 'old:
';
for($i=0;$i<$count;$i++) echo $array[$i].'
';
array_pop($array);
$count = count($array);
echo 'new:
';
for($i=0;$i<$count;$i++) echo $array[$i].'
';
?>
输出结果:
old:
PHP
JSP
ASP
new:
PHP
JSP
http://www.bkjia.com/PHPjc/629512.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/629512.htmlTechArticle用PHP4中带的array_pop这个函数即可,函数原型: mixed array_pop(array array) 举个例子: ? $array = array('PHP','JSP','ASP'); $count = count($array); echo 'old:br'; for(...