title: Sum an array in php by column
body: <p>I have this array : </p>
  
  <pre><code>$result = [
     0 =&gt; [
         category   =&gt; 'Solution',
         name       =&gt; 'Name1',
         value1     =&gt; 20
         value2     =&gt; 21
     ],
     1 =&gt; [
         category   =&gt; 'Solution',
         name       =&gt; 'Name2',
         value1     =&gt; 30,
         value2     =&gt; 31
     ],
     2 =&gt; [
         category   =&gt; 'Solution1',
         name       =&gt; 'Name3',
         value1     =&gt; 40,
         value2     =&gt; 41
     ]
  ]
  </code></pre>
  
  <p>I want to get an array : </p>
  
  <pre><code>$new_array = [
      0 =&gt; [
          name    =&gt; 'Solution',
          value1  =&gt; 50   // sum of array with key = 0 and key = 1
          value2  =&gt; 52
      ], 
      1 =&gt; [
          name    =&gt; 'Name1'
          value1  =&gt; 20,
          value2  =&gt; 21
      ],
      2 =&gt; [
          name    =&gt; 'Name2',
          value1  =&gt; 30,
          value2  =&gt; 31
      ],
      3 =&gt; [
          name    =&gt; 'Solution1',
          value1  =&gt; 40,
          value2  =&gt; 41
      ],
      4 =&gt; [
          name    =&gt; 'Name3',
          value1  =&gt; 40,
          value2  =&gt; 41
      ]
  ]
  </code></pre>
  
  <p>I tried like this :</p>
  
  <pre><code>private function groupByProductSuperCategory($datas)
  {
      $return = [];
      foreach ($datas as $data) {
          $return[$data['category']][$data['name']] = array_sum(array_column('category', $data);
      }
      return $return;
  }
  </code></pre>
  
  <p>The idea is to calculate first all sum values for by category, and after that just put values from name like another array. Have you an idea of how to do that ? Please help me.</p>