title: Array Merge with array value as key
body: <p>I am trying to convert an multi-dimentional array of product data where the PayPal email is set as one of the array values(can be same for some). I need help on merging those as arrays where the paypal_email key is same. Here is the <code>print_r</code> of the array that I have.  </p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [name] =&gt; Test Product
              [product_id] =&gt; 307
              [variation_id] =&gt; 0
              [subtotal] =&gt; 30
              [total] =&gt; 30
              [quantity] =&gt; 2
              [subtotal_tax] =&gt; 2.66
              [total_tax] =&gt; 2.66
              [paypal_email] =&gt; thisismytestpaypal@sandbox.com
              [vendor_id] =&gt; 2
              [shipping] =&gt; Array
                  (
                      [shipping_total] =&gt; 25.00
                      [shipping_tax] =&gt; 2.22
                  )
  
          )
  
      [1] =&gt; Array
          (
              [name] =&gt; Album
              [product_id] =&gt; 354
              [variation_id] =&gt; 0
              [subtotal] =&gt; 15
              [total] =&gt; 15
              [quantity] =&gt; 1
              [subtotal_tax] =&gt; 1.33
              [total_tax] =&gt; 1.33
              [paypal_email] =&gt; thisismytestpaypal@sandbox.com
              [vendor_id] =&gt; 11
              [shipping] =&gt; Array
                  (
                      [shipping_total] =&gt; 25.00
                      [shipping_tax] =&gt; 2.22
                  )
  
          )
  
      [2] =&gt; Array
          (
              [name] =&gt; Beanie with Logo
              [product_id] =&gt; 357
              [variation_id] =&gt; 0
              [subtotal] =&gt; 18
              [total] =&gt; 18
              [quantity] =&gt; 1
              [subtotal_tax] =&gt; 1.60
              [total_tax] =&gt; 1.60
              [paypal_email] =&gt; ab2@sandbox.com
              [vendor_id] =&gt; 10
              [shipping] =&gt; Array
                  (
                      [shipping_total] =&gt; 25.00
                      [shipping_tax] =&gt; 2.22
                  )
  
          )
  
      [3] =&gt; Array
          (
              [name] =&gt; Long Sleeve Tee
              [product_id] =&gt; 352
              [variation_id] =&gt; 0
              [subtotal] =&gt; 75
              [total] =&gt; 75
              [quantity] =&gt; 3
              [subtotal_tax] =&gt; 6.66
              [total_tax] =&gt; 6.66
              [paypal_email] =&gt; ab2@sandbox.com
              [vendor_id] =&gt; 2
              [shipping] =&gt; Array
                  (
                      [shipping_total] =&gt; 25.00
                      [shipping_tax] =&gt; 2.22
                  )
  
          )
  
      [4] =&gt; Array
          (
              [name] =&gt; Polo
              [product_id] =&gt; 353
              [variation_id] =&gt; 0
              [subtotal] =&gt; 80
              [total] =&gt; 80
              [quantity] =&gt; 4
              [subtotal_tax] =&gt; 7.10
              [total_tax] =&gt; 7.10
              [paypal_email] =&gt; tv3@sandbox.com
              [vendor_id] =&gt; 8
              [shipping] =&gt; Array
                  (
                      [shipping_total] =&gt; 25.00
                      [shipping_tax] =&gt; 2.22
                  )
  
          )
  
      [5] =&gt; Array
          (
              [name] =&gt; Product From Test Vendor 3
              [product_id] =&gt; 145
              [variation_id] =&gt; 0
              [subtotal] =&gt; 60
              [total] =&gt; 60
              [quantity] =&gt; 3
              [subtotal_tax] =&gt; 5.33
              [total_tax] =&gt; 5.33
              [paypal_email] =&gt; tv3@sandbox.com
              [vendor_id] =&gt; 10
              [shipping] =&gt; Array
                  (
                      [shipping_total] =&gt; 25.00
                      [shipping_tax] =&gt; 2.22
                  )
  
          )
  
      [6] =&gt; Array
          (
              [name] =&gt; Product From Vendor 1
              [product_id] =&gt; 143
              [variation_id] =&gt; 0
              [subtotal] =&gt; 20
              [total] =&gt; 20
              [quantity] =&gt; 2
              [subtotal_tax] =&gt; 1.78
              [total_tax] =&gt; 1.78
              [paypal_email] =&gt; tv1@sandbox.com
              [vendor_id] =&gt; 8
              [shipping] =&gt; Array
                  (
                      [shipping_total] =&gt; 25.00
                      [shipping_tax] =&gt; 2.22
                  )
  
          )
  
  )  
  </code></pre>
  
  <p>I need the array to merged as a multi-dimentional array with the paypal email as key and other data as values.. For example,  </p>
  
  <pre><code>Array
  (   [thisismytestpaypal@sandbox.com] =&gt; Array
          (
          [0] =&gt; Array
              (
                  [name] =&gt; Test Product
                  [product_id] =&gt; 307
                  [variation_id] =&gt; 0
                  [subtotal] =&gt; 30
                  [total] =&gt; 30
                  [quantity] =&gt; 2
                  [subtotal_tax] =&gt; 2.66
                  [total_tax] =&gt; 2.66
                  [paypal_email] =&gt; thisismytestpaypal@sandbox.com
                  [vendor_id] =&gt; 2
                  [shipping] =&gt; Array
                      (
                          [shipping_total] =&gt; 25.00
                          [shipping_tax] =&gt; 2.22
                      )
  
              )
  
          [1] =&gt; Array
              (
                  [name] =&gt; Album
                  [product_id] =&gt; 354
                  [variation_id] =&gt; 0
                  [subtotal] =&gt; 15
                  [total] =&gt; 15
                  [quantity] =&gt; 1
                  [subtotal_tax] =&gt; 1.33
                  [total_tax] =&gt; 1.33
                  [paypal_email] =&gt; thisismytestpaypal@sandbox.com
                  [vendor_id] =&gt; 11
                  [shipping] =&gt; Array
                      (
                          [shipping_total] =&gt; 25.00
                          [shipping_tax] =&gt; 2.22
                      )
  
              )
          )
  
      [ab2@sandbox.com] =&gt; Array
          (
          [0] =&gt; Array
              (
                  [name] =&gt; Beanie with Logo
                  [product_id] =&gt; 357
                  [variation_id] =&gt; 0
                  [subtotal] =&gt; 18
                  [total] =&gt; 18
                  [quantity] =&gt; 1
                  [subtotal_tax] =&gt; 1.60
                  [total_tax] =&gt; 1.60
                  [paypal_email] =&gt; ab2@sandbox.com
                  [vendor_id] =&gt; 10
                  [shipping] =&gt; Array
                      (
                          [shipping_total] =&gt; 25.00
                          [shipping_tax] =&gt; 2.22
                      )
  
              )
  
          [1] =&gt; Array
              (
                  [name] =&gt; Long Sleeve Tee
                  [product_id] =&gt; 352
                  [variation_id] =&gt; 0
                  [subtotal] =&gt; 75
                  [total] =&gt; 75
                  [quantity] =&gt; 3
                  [subtotal_tax] =&gt; 6.66
                  [total_tax] =&gt; 6.66
                  [paypal_email] =&gt; ab2@sandbox.com
                  [vendor_id] =&gt; 2
                  [shipping] =&gt; Array
                      (
                          [shipping_total] =&gt; 25.00
                          [shipping_tax] =&gt; 2.22
                      )
  
              )
          )
  
      [tv3@sandbox.com] =&gt; Array
          (
          [0] =&gt; Array
              (
                  [name] =&gt; Polo
                  [product_id] =&gt; 353
                  [variation_id] =&gt; 0
                  [subtotal] =&gt; 80
                  [total] =&gt; 80
                  [quantity] =&gt; 4
                  [subtotal_tax] =&gt; 7.10
                  [total_tax] =&gt; 7.10
                  [paypal_email] =&gt; tv3@sandbox.com
                  [vendor_id] =&gt; 8
                  [shipping] =&gt; Array
                      (
                          [shipping_total] =&gt; 25.00
                          [shipping_tax] =&gt; 2.22
                      )
  
              )
  
          [1] =&gt; Array
              (
                  [name] =&gt; Product From Test Vendor 3
                  [product_id] =&gt; 145
                  [variation_id] =&gt; 0
                  [subtotal] =&gt; 60
                  [total] =&gt; 60
                  [quantity] =&gt; 3
                  [subtotal_tax] =&gt; 5.33
                  [total_tax] =&gt; 5.33
                  [paypal_email] =&gt; tv3@sandbox.com
                  [vendor_id] =&gt; 10
                  [shipping] =&gt; Array
                      (
                          [shipping_total] =&gt; 25.00
                          [shipping_tax] =&gt; 2.22
                      )
  
              )
          )
      [tv1@sandbox.com] =&gt; Array
          (
          [0] =&gt; Array
              (
                  [name] =&gt; Product From Vendor 1
                  [product_id] =&gt; 143
                  [variation_id] =&gt; 0
                  [subtotal] =&gt; 20
                  [total] =&gt; 20
                  [quantity] =&gt; 2
                  [subtotal_tax] =&gt; 1.78
                  [total_tax] =&gt; 1.78
                  [paypal_email] =&gt; tv1@sandbox.com
                  [vendor_id] =&gt; 8
                  [shipping] =&gt; Array
                      (
                          [shipping_total] =&gt; 25.00
                          [shipping_tax] =&gt; 2.22
                      )
  
              )
          )
  
  )
  </code></pre>
  
  <p>How can I do that?<br>
  Thanks</p>