从PHP中的多维数组中删除具有空值的行 [英] Remove lines with empty values from multidimensional-array in php
本文介绍了从PHP中的多维数组中删除具有空值的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从PHP的多维数组中删除包含空元素的行?
How do you remove the lines that have empty elements from a multidimensional-array in PHP?
例如,来自:
1: a, b, c, d
2: d, _, b, a
3: a, b, _, _
4: d, c, b, a
5: _, b, c, d
6: d, c, b, a
到
1: a, b, c, d
4: d, c, b, a
6: d, c, b, a
谢谢!
推荐答案
$arr = array(... your multi dimension array here ...);
foreach($arr as $idx => $row) {
if (preg_grep('/^$/', $row)) {
unset($arr[$idx]);
}
}
这篇关于从PHP中的多维数组中删除具有空值的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文