I want to sum the values in each row of my associative array of associative rows.
My input:
[
"A" => ["AA" => 10],
"B" => ["BA" => 5, "BB" => 1, "BC" => -2],
"C" => ["CA" => 3, "CB" => 0]
]
Desired Result:
['A' => 10, 'B' => 4, 'C' => 3]
I've tried to do this with a foreach(), but the result is wrong.
Can someone demonstrate and explain how to do this?
var_export(array_map('array_sum', $arr));