如何从 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 - 从php中的多维数组中删除具有空值的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6944459/