title: Merge the sub array if it has the save id value?
body: <p>I have an array and I want to merge the sub array that have the same id value together:</p>
  
  <pre><code>    &lt;?php 
          $a = Array(
          Array
              (
              "id" =&gt; 1,
              "id_categorie" =&gt; 1,
              "nb" =&gt; 18
             ),
             Array
             (
              "id" =&gt; 1,
              "id_categorie" =&gt; 8,
              "nb" =&gt; 14
           ),
          Array
          (
              "id" =&gt; 2,
              "id_categorie" =&gt; 10,
              "nb" =&gt; 15
          )
  
  );
  $result = array();
  
  foreach ($a as $k=&gt;$v){
  
      $result[$v['id']] =$v; 
  
  
  }
  
  echo '&lt;pre&gt;';
  print_r($result);
  echo '&lt;/pre&gt;';    
  ?&gt;
  </code></pre>
  
  <p>I GOT:</p>
  
  <pre><code>Array
  (
      [1] =&gt; Array
          (
              [id] =&gt; 1
              [id_categorie] =&gt; 8
              [nb] =&gt; 14
          )
  
      [2] =&gt; Array
          (
              [id] =&gt; 2
              [id_categorie] =&gt; 10
              [nb] =&gt; 15
          )
  
  )
  </code></pre>
  
  <p>BUT WHAT I WANT IS :</p>
  
  <pre><code>Array
  (
      [1] =&gt; Array
          (
               Array
            (                   
                  "id_categorie" =&gt; 1,
                  "nb" =&gt; 18
             ),
           Array
           (                
               "id_categorie" =&gt; 8,
               "nb" =&gt; 14
           )
        )
  
      [2] =&gt; Array
          (
              [id_categorie] =&gt; 10
              [nb] =&gt; 15
          )
  
  )
  </code></pre>
  
  <p>Anyone could tell me how to do this? thanks</p>