是否可以按数组计算数组?
例如,计算 和[num]
每个[price]
的总和[group]
。
Array
(
[0] => Array
(
[group] => Apple
[num] => 5
[price] => 10
)
[1] => Array
(
[group] => Apple
[num] => 2
[price] => 8
)
[2] => Array
(
[group] => Orange
[num] => 4
[price] => 6
)
[3] => Array
(
[group] => Orange
[num] => 12
[price] => 24
)
)
结果将是:
Array
(
[0] => Array
(
[group] => Apple
[num] => 7
[price] => 18
)
[1] => Array
(
[group] => Orange
[num] => 16
[price] => 30
)
)