title: php foreach break table
body: <p>Im using tables to store content that's dynamically loaded. It's for a reservation form which will be responsive. What I'm looking to do is break each table row into two if there are more than 5 columns in order for the mobile version to fit on screen.</p>
  
  <p>I'm sure this can be achieved by extending what I already have but can't get it to work.</p>
  
  <p>Here's my current code:</p>
  
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
          &lt;?php foreach ($hostel-&gt;getAvailableDates() as $date): ?&gt;
          &lt;th&gt;&lt;?php echo $date-&gt;getDayOfTheWeek(); ?&gt;&lt;/th&gt;
          &lt;?php endforeach ?&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;?php foreach ($hostel-&gt;getAvailableDates() as $date): ?&gt;       
          &lt;td&gt;
          &lt;?php if($date-&gt;getAvailable()) { ?&gt;            
              &lt;b class="avail tick"&gt;Available&lt;/b&gt;
          &lt;?php } else { ?&gt;
              &lt;b class="avail cross"&gt;Unavailable&lt;/b&gt;
          &lt;?php }?&gt;
          &lt;/td&gt;
          &lt;?php endforeach ?&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I'd need to break the loop for each row <code>tr</code> after 5 loops, then add a new row underneath.
  I've been experimenting with </p>
  
  <pre><code>$max_loop = 5;
  $count = 0; 
  </code></pre>
  
  <p>But no luck so far.</p>