Home > php教程 > php手册 > php删除数组的最后一个元素和第一个元素

php删除数组的最后一个元素和第一个元素

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:44:16
Original
887 people have browsed it

用php4中带的array_pop这个函数即可,函数原型:
mixed array_pop(array array)
举个例子:

$array = array(php,jsp,asp);
$count = count($array);
echo old:
;
for($i=0;$i;
array_pop($array);
$count = count($array);
echo new:
;
for($i=0;$i;
?>
输出结果:
old:
php
jsp
asp
new:
php
jsp

php 删除数组第一个元素

$new_data = array_splice($insert_data, 1); //删除数组第一值

 作者“摇滚21的博客”
 

Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template