There are a number of great Q&As on Stackoverflow on how to sum across a multidimensional associative array but I have not found a working example of doing subtotals within
You can try this one:
foreach($myArray as &$value){ if(is_array($value)){ $value = array_sum($value); } }