I have 2 arrays as follows :-
$m_aggregate = array(
'weighted' => array (40000,
30000,
90000,
0),
'unweighted' => array (3000,
2000,
6000,
0),
'weighted_sum' => 160000,
'unweighted_sum' => 11000
);
$f_aggregate = array(
'weighted' => array (7000,
5000,
9000,
0),
'unweighted' => array (500,
300,
600,
0),
'weighted_sum' => 21000,
'unweighted_sum' => 1400
);
and wish to sum the individual elements so I get
$tot_aggregate = array(
'weighted' => array (47000,
35000,
99000,
0),
'unweighted' => array (3500,
2300,
6600,
0),
'weighted_sum' => 181000,
'unweighted_sum' => 12400
);
I've tried using
function sum($arr1, $arr2)
{
return($arr1+$arr2);
}
$tot_aggregate = array_map("sum", $m_aggregate, $f_aggregate);
print_r($tot_aggregate);
but this gives me weighted_sum and unweighted_sum , but not the weighted and unweighted arrays within the array summed.
Can anyone help? tia Jas