Clear a certain unit of the array in php
php中清除数组的某个单元要用unset(),不能用其他方式,例子如下:
<?php
$stu[0]="张三";
$stu[1]="李四";
$stu[2]="王五";
//清除李四这个单元
//$stu[1]=null;//赋值null结果不行
//$stu[1]='';//赋值空字符串结果也不行,空字符串也是一个值
//$stu[1]=false;//赋值bool值false结果也不行
unset($stu[1]);
print_r($stu);
Copy after login
http://www.bkjia.com/PHPjc/1070926.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1070926.htmlTechArticleTo clear a certain unit of an array in php, to clear a certain unit of an array in php, you need to use unset(), which cannot be used. Other methods, examples are as follows:?php$stu[0]=Zhang San;$stu[1]=Li Si;$stu[2]=王五;//Clear Li Si...