我有以下数组。如何删除那些[1]中没有值的值?因此,如果没有“x”,它将被删除。
在:
Array
(
[0] => Array
(
[0] => 1
[1] => x
[2] => name1
[3] => company1
[4] => 709
)
[1] => Array
(
[0] => 2
[1] => x
[2] => name2
[3] => company2
[4] => 500
)
.
.
.
[978] => Array
(
[0] => 946
[1] =>
[2] => name946
[3] => company946
[4] => 0
)
[979] => Array
(
[0] => 946
[1] => x
[2] => name946
[3] => company946
[4] => 0
)
[980] => Array
(
[0] => 946
[1] =>
[2] => name946
[3] => company946
[4] => 0
)
)
后:
Array
(
[0] => Array
(
[0] => 1
[1] => x
[2] => name1
[3] => company1
[4] => 709
)
[1] => Array
(
[0] => 2
[1] => x
[2] => name2
[3] => company2
[4] => 500
)
.
.
.
[979] => Array
(
[0] => 946
[1] => x
[2] => name946
[3] => company946
[4] => 0
)
)
答案 0 :(得分:-1)
只需循环你的桌子:
foreach($lines AS $k => $row) {
if($row[1] !== 'x') {
unset($lines[$k]);
}
}