title: using php to add classes to li then alternate after every third item?
body: <p>this may be stupidly simple but I'm trying to figure out a way to add a class to an unordered list, then alternate that class after every third item..</p>
  
  <p>I've only mananged to add a class on every third item (which is not what I want), but here's my code:</p>
  
  <pre><code>&lt;?php $i=1; foreach($this-&gt;items as $item) : ?&gt;
        &lt;li class="&lt;?php if ($i % 3 == 0) : ?&gt;odd&lt;?php endif; ?&gt;"&gt;&lt;a href="&lt;?php echo $linky; ?&gt;"&gt;xxx&lt;/a&gt;&lt;/li&gt;
  &lt;?php $i++; endforeach; ?&gt;
  </code></pre>
  
  <p>Which spits out:</p>
  
  <pre><code>&lt;li class=""&gt;xxx&lt;/li&gt;
  &lt;li class=""&gt;xxx&lt;/li&gt;
  &lt;li class="odd"&gt;xxx&lt;/li&gt;
  &lt;li class=""&gt;xxx&lt;/li&gt;
  &lt;li class=""&gt;xxx&lt;/li&gt;
  &lt;li class="odd"&gt;xxx&lt;/li&gt;
  </code></pre>
  
  <p>But what I'm hoping to get is:</p>
  
  <pre><code>&lt;li class="odd"&gt;xxx&lt;/li&gt;
  &lt;li class="odd"&gt;xxx&lt;/li&gt;
  &lt;li class="odd"&gt;xxx&lt;/li&gt;
  &lt;li class="even"&gt;xxx&lt;/li&gt;
  &lt;li class="even"&gt;xxx&lt;/li&gt;
  &lt;li class="even"&gt;xxx&lt;/li&gt;
  </code></pre>
  
  <p>and so forth.. Normally I'd use jquery to do something like this, but I have to use php in this case.. Any help would be greatly appreciated :)</p>