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 could do this using array_map() and array_sum():
$output = array_map(function($a) { return is_array($a) ? array_sum($a) : $a; }, $myArray);