我有一个关联数组(动态-可能有更多数组但相同的键):
Array
(
[food] => Array
(
[0] => 3
[1] => 4
[2] => 1
)
[liquor] => Array
(
[0] => 4
[1] => 5
[2] => 0
)
[beer] => Array
(
[0] => 5
[1] => 6
[2] => 0
)
)
我需要对每个数组使用array_sum,所以结果将是:
Array ( [food] => 8, [liquor] => 9, [beer] => 11 )
谢谢!
$result = array_map('array_sum', $your_array);
示例:http://ideone.com/LqTAV