title: Using do while loop inside a foreach
body: <p>I am doing this call to <a href="https://github.com/hristonev/sportmonks-client-bundle" rel="nofollow noreferrer">soccer api</a> inside a foreach loop to return each competition matches.
  This call works just fine if it's outside a foreach loop.
  When in foreach I only get the first competition array but then the array is not reseted! it keeps returning the same results for the first loop, I tried to unset the variables but that does not seem to work. any idea?</p>
  
  <pre><code>foreach($comps as $comp){
      $comp_api = $comp-&gt;comp_id;
      $from_date = new datetime($start_date);
      $to_date = new datetime($end_date);
      $matches_setup = ['query' =&gt; ['leagues' =&gt; $comp_id]];
  
      #loop matches
      $matches = array();
      do {
          $matches = array_merge($matches, $api-&gt;fixtures()-&gt;between()-&gt;period($from_date, $to_date, null, $matches_setup));
      } while ($monk_framework-&gt;fixtures()-&gt;nextPage($matches_setup));
      $results = $matches;
  
      /*
      * part where data is inserted to db
      */
  }
  </code></pre>
  
  <p>Is there something wrong with how am doing it? or this could be an issue with the api?</p>