title: Merge key values in a multidimensional array php
body: <p>I'd like to merge duplicated array values based on the <code>author_id</code> into one. My code is as follows:</p>
  
  <pre><code> public function full_array( $date_query, $minimum ) {          
      $data = $this-&gt;date_array_freqency( $date_query, $minimum );
      $products = array();
  
      foreach( $data as $id =&gt; $sales ) {
          $products[] = array (
              'author_id'     =&gt; get_post_field( 'post_author', $id ),
              'product_id'    =&gt; $id,
              'sales'         =&gt; $sales                   
            );
      }           
  }
  </code></pre>
  
  <p>Multi-dimensional array looks like this:</p>
  
  <pre><code>Array
  (
      ....
  
      [4] =&gt; Array
          (
              [author_id] =&gt; 27
              [product_id] =&gt; 166
              [sales] =&gt; 6
          )
  
      [5] =&gt; Array
          (
              [author_id] =&gt; 25
              [product_id] =&gt; 1056
              [sales] =&gt; 6
          )
  
      [6] =&gt; Array
          (
              [author_id] =&gt; 27
              [product_id] =&gt; 331
              [sales] =&gt; 6
          )
  
  )
  </code></pre>
  
  <p>When there's an identical author id, I'd like to combine the array into something like this:</p>
  
  <pre><code>[4] =&gt; Array
          (
              [author_id] =&gt; 27
              [product_id] =&gt; array( 166, 331)
              [sales] =&gt; array(6, 6)
          )
  </code></pre>
  
  <p>Any guidance is much appreciated.</p>