title: How to add an html element at each two items with foreach or SPL?
body: <p>How can I interrupt a loop and adding an html element at each <strong>two</strong> iterations? Can a simple <code>foreach</code> do that or something in <code>SPL</code>?</p>
  
  <pre><code>&lt;?php foreach($items as $index=&gt;$item): ?&gt;
       &lt;li&gt;$item-&gt;title&lt;/li&gt;
       &lt;?php if($index + 1 = 2):?&gt;
       &lt;div class="divider"&gt;&lt;/div&gt;
       &lt;?php endif;?&gt; 
  &lt;?php endforeach;?&gt;
  </code></pre>
  
  <p>html result,</p>
  
  <pre><code>&lt;li&gt;title 1&lt;/li&gt;
  &lt;li&gt;title 2&lt;/li&gt;
  &lt;div class="divider"&gt;&lt;/div&gt;
  &lt;li&gt;title 3&lt;/li&gt;
  &lt;li&gt;title 4&lt;/li&gt;
  &lt;div class="divider"&gt;&lt;/div&gt;
  &lt;li&gt;title 5&lt;/li&gt;
  &lt;li&gt;title 6&lt;/li&gt;
  &lt;div class="divider"&gt;&lt;/div&gt;
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>&lt;li&gt;title 1&lt;/li&gt;
  &lt;li&gt;title 2&lt;/li&gt;
  &lt;li&gt;title 3&lt;/li&gt;
  &lt;div class="divider"&gt;&lt;/div&gt;
  &lt;li&gt;title 4&lt;/li&gt;
  &lt;li&gt;title 5&lt;/li&gt;
  &lt;div class="divider"&gt;&lt;/div&gt;
  &lt;li&gt;title 6&lt;/li&gt;
  </code></pre>