Home >Backend Development >PHP Tutorial >数组去空 求教

数组去空 求教

WBOY
WBOYOriginal
2016-06-23 13:37:511028browse






现在是206条记录, 有的记录中,部分为空。 一条记录中全部为空时,才释放这个下标的记录(可以判断全部,或这里有个特殊下标,status为空时,这条记录就都为空,如array[1] 就是所有元素都为空)

$countarr = count($newplayer);
for($i=0;$i if($newplayer[$i]['status']=='' ){
unset($newplayer[$i]);
}
}

不好使


回复讨论(解决方案)

忘记说 谢谢了,  先谢了啊 

<?php $arr=array(array("key2","","value"),			array("","key3","value"),			array());	echo '<pre class="brush:php;toolbar:false">';	print_r($arr);	foreach($arr as $key=>$val){		$num=0;		foreach($val as $key1=>$val1){			if(empty($val1)){				unset($arr[$key][$key1]);			}else{				$num++;			}		}		if($num==0){			unset($arr[$key]);		}else{			sort($arr[$key]);		}			}	sort($arr);	print_r($arr);echo '
';?>
不知道楼主是不是想要这样的效果,新人刚玩这个社区,大家交流下哈

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