从php中的multidimensional-array中删除空值的行

Ale*_*lex 2 php multidimensional-array

如何从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
Run Code Online (Sandbox Code Playgroud)

1: a, b, c, d
4: d, c, b, a
6: d, c, b, a
Run Code Online (Sandbox Code Playgroud)

谢谢!

Mar*_*c B 7

$arr = array(... your multi dimension array here ...);
foreach($arr as $idx => $row) {
    if (preg_grep('/^$/', $row)) {
        unset($arr[$idx]);
    }
}
Run Code Online (Sandbox Code Playgroud)