Home  >  Article  >  Backend Development  >  PHP deletes the last element and first element of an array_PHP tutorial

PHP deletes the last element and first element of an array_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:45:44694browse

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

php delete the first element of array

$new_data = array_splice($insert_data, 1); //Delete the first value of the array

Author "Rock 21's Blog"

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478649.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($i=0;$i...
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