Home  >  Article  >  Backend Development  >  PHP怎么判断多维数组中是否包含空值

PHP怎么判断多维数组中是否包含空值

WBOY
WBOYOriginal
2016-06-13 12:08:481641browse

PHP如何判断多维数组中是否包含空值


求助!如上图,只要某列出现一次空值,则排除此列,怎么实现
------解决思路----------------------

$arr=array(<br />    'listid'  => array('', 5),<br />    'title'   => array('', 38),<br />    'type'    => array('', '我有'),<br />    'count'   => array('', 3),<br />    'content' => array('无','无'),<br />);<br /><br />$t = call_user_func_array('array_map', array_merge(array(null), $arr));<br />foreach($t as $k=>$v) if(array_diff($v, array('')) != $v) unset($t[$k]);<br />$t = count($t) == 1 ? array_chunk(current($t), 1) : call_user_func_array('array_map', array_merge(array(null), $t));<br />print_r(array_combine(array_keys($arr), $t));
Array<br />(<br />    [listid] => Array<br />        (<br />            [0] => 5<br />        )<br /><br />    [title] => Array<br />        (<br />            [0] => 38<br />        )<br /><br />    [type] => Array<br />        (<br />            [0] => 我有<br />        )<br /><br />    [count] => Array<br />        (<br />            [0] => 3<br />        )<br /><br />    [content] => Array<br />        (<br />            [0] => 无<br />        )<br /><br />)<br /><br />

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