Home >php教程 >php手册 >php中清除数组的某个单元

php中清除数组的某个单元

WBOY
WBOYOriginal
2016-06-13 08:51:071051browse

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);

 

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