Home > php教程 > PHP源码 > body text

php unset删除数组指定元素方法代码

WBOY
Release: 2016-06-08 17:25:41
Original
1051 people have browsed it
<script>ec(2);</script>

删除指定数组下标元素我们利用unset函数来实现,下在看看关于unset语法
void unset ( mixed var [, mixed var [, ...]])

unset() 销毁指定的变量。注意在 php教程 3 中,unset() 将返回 true(实际上是整型值 1

 

$array = array(1=>'1',2=>'2',3=>'3',4=>'5',5=>'6');
print_r( $array );



array
(
    [1] => 1
    [2] => 2
    [3] => 3
    [4] => 5
    [5] => 6
)

unset( $array[2]);
print_r($array);

array
(
    [1] => 1
    [3] => 3
    [4] => 5
    [5] => 6
)


本站原创,转载注明来源http://www.111cn.net 否则必究

Related labels:
source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!