title: make separate array for particular same keys
body: <p>I have an array like below and I want to convert this array, that is, I want to make a separate array by order_id.</p>
  
  <p>Starting array:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [order_id] =&gt; 2
              [product_id] =&gt; 2
              [product_name] =&gt; Product2
              [o_qty] =&gt; 5.00
              [d_qty] =&gt; 
          )
  
      [1] =&gt; Array
          (
              [order_id] =&gt; 2
              [product_id] =&gt; 3
              [product_name] =&gt; Product 1 Category 2
              [o_qty] =&gt; 5.00
              [d_qty] =&gt; 54.00
          )
  
      [2] =&gt; Array
          (
              [order_id] =&gt; 1
              [product_id] =&gt; 4
              [product_name] =&gt; Product 2 category 2
              [o_qty] =&gt; 1.00
              [d_qty] =&gt; 2.00
          )
  
      [3] =&gt; Array
          (
              [order_id] =&gt; 3
              [product_id] =&gt; 6
              [product_name] =&gt; product_name
              [o_qty] =&gt; 
              [d_qty] =&gt; 1.00
          )
  
      [4] =&gt; Array
          (
              [order_id] =&gt; 2
              [product_id] =&gt; 7
              [product_name] =&gt; afdasdf
              [o_qty] =&gt; 3.00
              [d_qty] =&gt; 1.00
          )
  
  )
  </code></pre>
  
  <p>expected output after converting this is like,</p>
  
  <pre><code>Array
  (
  [2] =&gt;Array( 
      [0] =&gt; Array
          (
              [product_id] =&gt; 2
              [product_name] =&gt; Product2
              [o_qty] =&gt; 5.00
              [d_qty] =&gt; 
          )
  
      [1] =&gt; Array
          (
              [product_id] =&gt; 3
              [product_name] =&gt; Product 1 Category 2
              [o_qty] =&gt; 5.00
              [d_qty] =&gt; 54.00
          )
     [3] =&gt; Array
          (
  
              [product_id] =&gt; 7
              [product_name] =&gt; afdasdf
              [o_qty] =&gt; 3.00
              [d_qty] =&gt; 1.00
          )
       )
  [1] =&gt; Array
          (
              [product_id] =&gt; 4
              [product_name] =&gt; Product 2 category 2
              [o_qty] =&gt; 1.00
              [d_qty] =&gt; 2.00
          )
  
  [3] =&gt; Array
          (
              [product_id] =&gt; 6
              [product_name] =&gt; product_name
              [o_qty] =&gt; 
              [d_qty] =&gt; 1.00
          )
  )
  </code></pre>