i have already function that SUM sub arrays which has matches keys like this
$totals = array();
$count_loops = 0 ;
// First get our totals.
foreach ($average as $subKey => $subArray) {
foreach ($subArray as $k => $v) {
// Add the column to our total.
$totals[$k] = isset($totals[$k] ) ? $totals[$k] + $v / $count_loops : $v;
}
}
and return total array like this
Array
(
[john_total] => 519.44
[adam_total] => 1664.64
[sara_total] => 1237.53
}
but i want to return average after sum bu divide sum number with count loops,but it return wrong average..if i delete this code / $count_loops
it sum good..so how to do this