Home  >  Article  >  Backend Development  >  php中清除数组的某个单元_PHP教程

php中清除数组的某个单元_PHP教程

WBOY
WBOYOriginal
2016-07-12 09:05:00789browse

php中清除数组的某个单元

php中清除数组的某个单元要用unset(),不能用其他方式,例子如下:
<?php
$stu[0]="张三";
$stu[1]="李四";
$stu[2]="王五";
//清除李四这个单元
//$stu[1]=null;//赋值null结果不行
//$stu[1]=&#39;&#39;;//赋值空字符串结果也不行,空字符串也是一个值
//$stu[1]=false;//赋值bool值false结果也不行
unset($stu[1]);
print_r($stu);

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1070926.htmlTechArticlephp中清除数组的某个单元 php中清除数组的某个单元要用unset(),不能用其他方式,例子如下:?php$stu[0]=张三;$stu[1]=李四;$stu[2]=王五;//清除李四...
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