title: Two items per foreach loop
body: <p>Apologies if this has already been asked (I cannot find an answer) but I am using PHP and I am building a slider, but would like two images per slide, not one. So, in theory the <code>foreach()</code> needs to include two per each.</p>
  
  <p>An example of the setup is as follows:</p>
  
  <pre><code>&lt;?php foreach ($page-&gt;images as $image) : ?&gt;
      &lt;img src="&lt;?php echo $image-&gt;url; ?&gt;"/&gt; 
  &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>I was thinking I could do something like a count...</p>
  
  <pre><code>&lt;?php $index = 0; foreach ($page-&gt;images as $image) : ?&gt;
      &lt;img src="&lt;?php echo $image-&gt;url; ?&gt;"/&gt;
      &lt;?php $index++; ?&gt;
      &lt;?php if ( $index % 2 == 0 &amp;&amp; $index !=count($page-&gt;images) ) : ?&gt;
      &lt;li&gt;&lt;/li&gt;
      &lt;?php endif; ?&gt;
  &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>But I got a little confused as this would insert something every 2... not include two of whatever the foreach loop is fetching at once.</p>
  
  <p>Hope this makes sense and thanks in advance</p>