Want to sum all column values in multi-dimensional array? Use the below PHP example to sum all column values in multidimensional array.
1 2 3 4 5 6 7 8 9 | $sumArray = array(); foreach ($myArray as $k=>$subArray) { foreach ($subArray as $id=>$value) { $sumArray[$id]+=$value; } } print_r($sumArray); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.