title: php merge 'subsets' of array in loop
body: <p>I'm struggling merging subsets of an array in a loop.</p>
  
  <p>I have a big array that can contain any amount of $data records (depending on the API results)</p>
  
  <p>When I try to merge just 2 'products' subsets this works just fine:</p>
  
  <pre><code>$merged=array_merge($data[0][products], $data[1][products]);
  </code></pre>
  
  <p>But since I don't know in advance how many $data records I will end up with I decided to do it in a loop, something like this:</p>
  
  <pre><code>foreach ($data as $products) {
  $merged=array_merge($merged,$products[products]);
  }
  </code></pre>
  
  <p>This doesn't work, I've been playing around with this for a couple of hours, but haven't been able to get it to work.</p>