Home >Backend Development >PHP Tutorial >How to delete the last element of an array?_PHP Tutorial

How to delete the last element of an array?_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:12:14832browse

Just use the array_pop function in PHP4. Function prototype:
mixed array_pop(array array)
For example:
$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].'
';
?>
Output result:
old :
PHP
JSP
ASP
new:
PHP
JSP

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629512.htmlTechArticleUse the array_pop function in PHP4. Function prototype: mixed array_pop(array array) For example: ? $array = array('PHP','JSP','ASP'); $count = count($array); echo 'old:br'; for(...
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