我有以下数组。(var_dump 输出)我想将这些相同的关键元素组合到单个数组中。我怎么做?
array (size=3)
'totals' =>
array (size=3)
0 =>
array (size=1)
'total' => string '4' (length=1)
1 =>
array (size=1)
'total' => string '50' (length=2)
2 =>
array (size=1)
'total' => string '44' (length=2)
'styles' =>
array (size=3)
0 =>
array (size=1)
'style' => string '11' (length=2)
1 =>
array (size=1)
'style' => string 'aaa' (length=3)
2 =>
array (size=1)
'style' => string 'bb' (length=3)
'colors' =>
array (size=3)
0 =>
array (size=1)
'color' => string '11' (length=2)
1 =>
array (size=1)
'color' => string 'ccc' (length=3)
2 =>
array (size=1)
'color' => string 'ddd' (length=3)
最终输出应该是这样的,
'totals' =>
array (size=3)
0 =>
array (size=1)
'total' => string '4' (length=1)
'style' => string '11' (length=2)
'color' => string '11' (length=2)
'styles' =>
array (size=3)
1 =>
array (size=1)
'total' => string '50' (length=2)
'style' => string 'aaa' (length=3)
'color' => string 'bb' (length=3)
'colors' =>
array (size=3)
2 =>
array (size=1)
'total' => string '44' (length=2)
'style' => string 'ccc' (length=3)
'color' => string 'ddd' (length=3)