title: Split a multidimensional array and use that in a query to create another array that has to be split
body: <p>At the moment I have this array:</p>
  
  <p><a href="http://pastebin.com/LsMaV38g" rel="nofollow">http://pastebin.com/LsMaV38g</a></p>
  
  <p>As you can see there are 2 arrays within.</p>
  
  <p>So to actually go through both arrays seperately, I use this for loop:</p>
  
  <pre><code>for($x = 0; $x&lt; count($array); $x++){
      var_dump($array[$x]);
  }
  </code></pre>
  
  <p>And I get both arrays back without the main array.(How I want it).</p>
  
  <p>After this I use another for loop to get the results of both arrays seperately as well:</p>
  
  <pre><code>for($i = 0; $i&lt; count($array[$x]); $i++){
     $query[] = DB::table('table')-&gt;where('id',$array[$x][$i]-&gt;somefield)-&gt;get();
  }
  </code></pre>
  
  <p>Now with this loop, I also get results from a database(as you might have already seen). Every Select query I run in that loop, always returns 1 row. So the amount of results of the query is the same as the amount of results of both arrays. Now if you look at the amount of results in the pastebin, you'll notice the query will return 5 results.(3 results in the first array and 2 in the second array). So the $query consists of 5 results but I want them to be seperated as well. The problem with this is, in this $query array there is no way to see which result belongs to which array. So something has to be done with the $array, but I can seem to figure out what to do to actually get the results of the query seperated like the arrays I use to get the results.  Does anyone know how to do this?</p>
  
  <p>the for loops together:</p>
  
  <pre><code>for($x = 0; $x&lt; count($array); $x++){
      var_dump($array[$x]);
      for($i = 0; $i&lt; count($array[$x]); $i++){
        $query[] = DB::table('table')-&gt;where('id',$array[$x][$i]-&gt;somefield)-&gt;get();
      }
  }
  </code></pre>