PHP Simple Even or Odd classes in loop

<?php $j = 0; foreach( $items as $item) : $j++; echo '<div class="'.($j%2 ? 'odd':'even').'>'; endforeach; ?>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.