title: Easiest way to alternate row colors in PHP/HTML?
body: <p>Here's a PHP example of mine. Can anyone find a shorter/easier way to do this?</p>
  
  <pre><code>&lt;? foreach($posts as $post){?&gt;
      &lt;div class="&lt;?=($c++%2==1)?‘odd’:NULL?&gt;"&gt;
          &lt;?=$post?&gt;
      &lt;/div&gt;
  &lt;? }?&gt;
  
  &lt;style&gt;
      .odd{background-color:red;}
  &lt;/style&gt;
  </code></pre>
  
  <p>Examples in other languages would be fun to see as well.</p>