title: How can I combine two arrays by key and value?
body: <p>This is my array "products":</p>
  
  <pre><code>array:3 [▼
    0 =&gt; array:8 [▼
      "uuid" =&gt; "78f895684c"
      "Name" =&gt; "test1"
    ]
    1 =&gt; array:8 [▼
      "uuid" =&gt; "f71db561ba"
      "Name" =&gt; "Zwei"
    ]
    2 =&gt; array:8 [▼
      "uuid" =&gt; "3e231651de"
      "Name" =&gt; "Test3"
    ]
  ]
  </code></pre>
  
  <p>This is my array "category":</p>
  
  <pre><code>array:3 [▼
    "78f895684c" =&gt; "pink"
    "f71db561ba" =&gt; "blue"
    "3e231651de" =&gt; "pink"
  ]
  </code></pre>
  
  <p>I try to create a new array, that sort my products into the category.
  This is my approach:</p>
  
  <pre><code> foreach ($products as $key =&gt; $value) {
     $test = $category[$value["uuid"]];
     $new[$test] = array();
     array_push($new,$value);
   }
  </code></pre>
  
  <p>The result I expect is:</p>
  
  <pre><code>array:5 [▼
    "blue" =&gt; 
       [0] =&gt; array:2 [▼
        "uuid" =&gt; "f71db561ba"
        "Name" =&gt; "Zwei"
    ]
    "pink" =&gt; 
      [1] =&gt; array:2 [▼
         "uuid" =&gt; "78f895684c"
         "Name" =&gt; "test1"
      [2] =&gt; array:2 [▼
      "uuid" =&gt; "3e231651de"
      "Name" =&gt; "Test3"
    ]
  ]
  </code></pre>
  
  <p>But my result is:</p>
  
  <pre><code>array:5 [▼
    "pink" =&gt; []
    0 =&gt; array:8 [▼
      "uuid" =&gt; "78f895684c"
      "Name" =&gt; "test1"
    ]
    "blue" =&gt; []
    1 =&gt; array:8 [▼
      "uuid" =&gt; "f71db561ba"
      "Name" =&gt; "Zwei"
    ]
    2 =&gt; array:8 [▼
      "uuid" =&gt; "3e231651de"
      "Name" =&gt; "Test3"
    ]
  ]
  </code></pre>