PHP nth foreach record
<p>I am looking for a way to do slightly more complicated nth record adjudtments, similar to jQuery's / CSS3 <code>nth-child(3n-1)</code> in PHP, so there are three cols per row and the mid one needs to have the class "mid" added. I preferably don't want to use jQuery as there always seems to be a lag from the page load and the class being added.</p>

<p>So something like below but i am aware that this would mean <code>$zxc % 2</code>, but we all start somewhere.</p>

<pre><code>&lt;?php $zxc = 1; ?&gt;
&lt;?php foreach($products as $product): ?&gt;
&lt;div class="theProductListItem&lt;?php if($zxc % (3-1) == 0){?&gt; mid&lt;?php } ?&gt;"&gt;
&lt;!--product contents--&gt;
&lt;/div&gt;
&lt;?php $zxc++; ?&gt;
&lt;?php endforeach; ?&gt;
</code></pre>
