2
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 个键的子阵列,那就是“强度”?

4

2 回答 2

6
$array = array_filter($array, function (array $i) {
    return count($i) != 1 || key($i) != 'intensity';
});
于 2012-12-26T13:55:18.933 回答
3
foreach($yourArray as $key => $value)
  if (is_array($value) && count($value) == 1 && isset($value['intensity']))
    unset($yourArray[$key]);
于 2012-12-26T13:56:03.983 回答