Get sum of multi-dimensional array in PHP -
I need to get the sum of all the numerical values in my array for each named month. Ideally, The format will return.
Total = 22
March
Total = 'Yoga'
Array ( [April] = & gt; Array ([0] => 1 [1] => 2 [2] => 3 [3] => [4] => 3 [5] ] => [6] => 2 [7] => 6 [8] => 3 [9] => 2) [march] => Hey ([0] = & Gt; 3.19198 [1] => 2.52219 [2] => 3.40053 [3] => 2.42639 [4] => 3.92301 [5] => 3.23758 [6] = & 3.22457 [7] = & gt; 2.62855)
on each sub-array Apply:
$ result = array_map ('array_sum', $ data);
Where Tput:
array ([April] => 22 [March] => 24.5548)
Comments
Post a Comment