我有下面的数组
Array
(
[0] => Array
(
[group_description] => Group 1
[services] => Array
(
[0] => Array
(
[service_id] => 1
[service_name] => Security
[service_total] => 10
)
[1] => Array
(
[service_id] => 4
[service_name] => Catering
[service_total] => 20
)
)
)
[1] => Array
(
[group_description] => Group 2
[services] => Array
(
[0] => Array
(
[service_id] => 1
[service_name] => Security
[service_total] => 6
)
[1] => Array
(
[service_id] => 4
[service_name] => Catering
[service_total] => 15
)
[2] => Array
(
[service_id] => 5
[service_name] => Lighting
[service_total] => 8
)
)
)
)
我想对具有相同服务的数组求和并创建一个总数组并像这样放回数组
我试过循环数组并在循环时创建一个新数组。我使用了一个 foreach 循环,然后使用 array_search 函数来查看我在忙于哪个并追加到新数组。但它没有达到我想要的效果,我总是以相同的数组结束。就像我真的陷入了一个循环。我看过很多例子,但我认为我的案例与例子不相似
至尊宝的传说