title: Combine sub arrays in PHP
body: <p>I am trying to combine array(s) by key. So all sub arrays that start with the same sub-key will be combined into one sub array. Also, I want to keep the smallest value of the matched values.</p>
  
  <p>Currently this is what I have:</p>
  
  <pre><code>$statement = Array
  (
      [662_0] =&gt; Array
          (
              [0] =&gt; 06-01-2012
              [1] =&gt; 436
              [2] =&gt; MEDIA
              [3] =&gt; 2006
              [4] =&gt; Template Testing
              [5] =&gt; KS
              [6] =&gt; 662
              [7] =&gt; 0
              [8] =&gt; 0
              [9] =&gt; 0
              [10] =&gt; 0
              [11] =&gt; 0
              [12] =&gt; 1290
              [13] =&gt; 1290.00
              [14] =&gt; 0.00
              [15] =&gt; 0
              [16] =&gt; 1290.00
          )
  
      [662_1] =&gt; Array
          (
              [0] =&gt; 06-01-2012
              [1] =&gt; 436
              [2] =&gt; MEDIA
              [3] =&gt; 2006
              [4] =&gt; Template Testing
              [5] =&gt; KS
              [6] =&gt; 662
              [7] =&gt; 295.00
              [8] =&gt; 0
              [9] =&gt; 0
              [10] =&gt; 0
              [11] =&gt; 0
              [12] =&gt; 995
              [13] =&gt; 1290.00
              [14] =&gt; 0.00
              [15] =&gt; 0
              [16] =&gt; 1290.00
          )
  
      [662_2] =&gt; Array
          (
              [0] =&gt; 06-01-2012
              [1] =&gt; 436
              [2] =&gt; MEDIA
              [3] =&gt; 2006
              [4] =&gt; Template Testing
              [5] =&gt; KS
              [6] =&gt; 662
              [7] =&gt; 0
              [8] =&gt; 0
              [9] =&gt; 0
              [10] =&gt; 0
              [11] =&gt; 0
              [12] =&gt; 1290
              [13] =&gt; 1290.00
              [14] =&gt; 0.00
              [15] =&gt; 0
              [16] =&gt; 1290.00
          )
  
      [663_0] =&gt; Array
          (
              blah blah blah...
          )
  );
  </code></pre>
  
  <p>This is what I would like to have:</p>
  
  <pre><code>$statement = Array
  (
      [662] =&gt; Array
          (
              [0] =&gt; 06-01-2012
              [1] =&gt; 436
              [2] =&gt; MEDIA
              [3] =&gt; 2006
              [4] =&gt; Template Testing
              [5] =&gt; KS
              [6] =&gt; 662
              [7] =&gt; 295.00
              [8] =&gt; 0
              [9] =&gt; 0
              [10] =&gt; 0
              [11] =&gt; 0
              [12] =&gt; 995
              [13] =&gt; 1290.00
              [14] =&gt; 0.00
              [15] =&gt; 0
              [16] =&gt; 1290.00
          )
  
      [663] =&gt; Array
          (
              blah blah blah...
          )
  );
  </code></pre>
  
  <p>Happy to provide more info if needed! Thanks!!!</p>