原始数组采用以下格式:
[att] => Array
(
[0] => Array
(
[id] => 18
[day_id] => 27
)
[1] => Array
(
[id] => 20
[day_id] => 32
)
)
和数组键需要按day_id
更改,如下所示:
[att] => Array
(
[27] => Array
(
[id] => 18
[day_id] => 27
)
[32] => Array
(
[id] => 20
[day_id] => 32
)
)
答案 0 :(得分:2)
最简单的方法:
$array['att'] = array_column($array['att'], null, 'day_id');