title: On every third iteration in PHP
body: <p>I would like to output some specific HTML on the third iteration of a loop in PHP. Here is my code:</p>
  
  <pre><code>&lt;?php foreach ($imgArray as $row): ?&gt;
     &lt;div class="img_grid"&gt;&lt;?= $row ?&gt;&lt;/div&gt;
  &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>On the third iteration of this loop, Instead of displaying:</p>
  
  <pre><code>&lt;div class="img_grid"&gt;&lt;?= $row ?&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I would like to display:</p>
  
  <pre><code>&lt;div class="img_grid_3"&gt;&lt;?= $row ?&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I would like to end up with this if my array looped 8 times:</p>
  
  <pre><code>   &lt;div class="img_grid"&gt;[some html]&lt;/div&gt;
     &lt;div class="img_grid"&gt;[some html]&lt;/div&gt;
     &lt;div class="img_grid_3"&gt;[some html]&lt;/div&gt;
     &lt;div class="img_grid"&gt;[some html]&lt;/div&gt;
     &lt;div class="img_grid"&gt;[some html]&lt;/div&gt;
     &lt;div class="img_grid_3"&gt;[some html]&lt;/div&gt;
     &lt;div class="img_grid"&gt;[some html]&lt;/div&gt;
     &lt;div class="img_grid"&gt;[some html]&lt;/div&gt;
  </code></pre>
  
  <p>Thanks</p>