title: Foreach loop item groups must add up to 3
body: <p>I am coding a PHP foreach loop.  I am using the following code to ensure that only 3 items are grouped into a .slide div container.</p>
  
  <pre><code>&lt;?php 
  $count = 0;
  foreach ($listing as $item):?&gt;
  &lt;div class='slide&gt;
  
    &lt;div class='item'&gt;Item&lt;/div&gt;
  
  &lt;?php if ($count++ % 3 == 1 ): ?&gt;
  &lt;/div&gt;
  &lt;div class="slide"&gt;
  &lt;?php endif; ?&gt;
  
  &lt;?php endforeach ?&gt;
  </code></pre>
  
  <p>I need to always have 3 items per group.  What is the best way to add items from the start of the array to fill up the remaining items?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>An example of the markup I need is:</p>
  
  <pre><code>&lt;div class='slide'&gt;
    &lt;div class='item'&gt;Item 1&lt;/div&gt;
    &lt;div class='item'&gt;Item 2&lt;/div&gt;
    &lt;div class='item'&gt;Item 3&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class='slide'&gt;
    &lt;div class='item'&gt;Item 4&lt;/div&gt;
    &lt;div class='item'&gt;Item 1&lt;/div&gt;
    &lt;div class='item'&gt;Item 2&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So if there is not 3 items per .slide  the array starts again to fill it up.</p>