Array
(
[9-1] => Array
(
[intensity] => 1
[time] => 43932
)
[9-2] => Array
(
[intensity] => 1
)
[85-1] => Array
(
[intensity] => 1
[time] => 40271
)
[85-2] => Array
(
[intensity] => 1
)
)
如何删除只有1个键的子阵列,即“强度”?
答案 0 :(得分:6)
$array = array_filter($array, function (array $i) {
return count($i) != 1 || key($i) != 'intensity';
});
答案 1 :(得分:3)
foreach($yourArray as $key => $value)
if (is_array($value) && count($value) == 1 && isset($value['intensity']))
unset($yourArray[$key]);