我有这个多维数组:
Array
(
[0] => Array
(
[name] => lorem
[id] => 1
[type] => Q1
[q1] => 39.55
[q2] => 0
)
[1] => Array
(
[name] => lorem
[id] => 1
[type] => Q2
[q1] => 0;
[q2] => 39.55
)
[2] => Array
(
[name] => lorem
[id] => 1
[type] => Q1
[q1] => 39.55
[q2] => 39.55
)
[3] => Array
(
[owner_name] => name
[id] => 2
[type] => Q1
[q1] => 39.55
[q2] => 0
)
)
我希望将数组中所有项目与相同的id组合在一起,并将同一所有者中的所有q1和q2组合在同一类型中,从而创建新的数组结构:
Array
(
[0] => Array
(
[name] => lorem
[id] => 1
[Q1_total = > 79.1
[q2_total] => 79.1
)
[1] => Array
(
[owner_name] => name
[id] => 2
[type] => Q1
[Q1_total] => 39.55
[Q2_total] => 0;
)
)