Need a little help here with summing up arrays inside a multi dimensional php array
Eg Multidimensional array
Array
(
[0] => Array
(
This should work for arrays like the one of your example ($arr
is an array like the one in your example, I haven't defined it here for simplicity's sake):
$res = array();
foreach($arr as $value) {
foreach($value as $key => $number) {
(!isset($res[$key])) ?
$res[$key] = $number :
$res[$key] += $number;
}
}
print_r($res);