How to sum all column values in multi-dimensional array?

后端 未结 20 2572
花落未央
花落未央 2020-11-22 00:57

How can I add all the columnar values by associative key? Note that key sets are dynamic.

Input array:

Arr         


        
20条回答
  •  無奈伤痛
    2020-11-22 01:35

        $resultat = array();
    
    foreach ($myArray as $myArray_key => $myArray_data) {
        foreach ($myArray_data as $key => $data) {
            $resultat[$key] += $data;
        }
    }
    
    print_r($resultat);
    

提交回复
热议问题