如何按数组中的某些值对数组元素进行分组?
例如,考虑以下数组数组。我想通过其 ID 对数组进行分组/连接/附加
$array['key1'] => Array (
[0] => Array(
'id' => 567,
'value' => 780
),
[1] => Array(
'id' => 676,
'value' => 743
),
[2] => Array(
'id' => 676,
'value' => 721
),
[3] => Array(
'id' => 234,
'value' => 766
),
[4] => Array(
'id' => 234,
'value' => 780
)
)
期望的输出:
$array['key1'] => Array (
[0] => Array(
'id' => 567,
'value' => 780
),
[1] => Array(
'id' => 676,
'value' => Array(
[0] => 743,
[1] => 721
)
),
[2] => Array(
'id' => 234,
'value' => Array(
[0] => 766,
[1] => 680
)
),
)
我怎样才能做到这一点?