[Solved] Sum up values in multidimensional php array [closed]


Assuming $arr is your initial array, and $new_arr will be the new one.

$new_arr = array();
foreach ($arr as $i=>$ar)
    foreach ($ar as $j=>$a)
        $new_arr[$i][$j] = round(($a/array_sum($ar))*100, 1);

solved Sum up values in multidimensional php array [closed]