Odd and Even classes


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $count = 0;
  2. foreach ($images as $image) {
  3. $count++;
  4. $odd_even = ceil($count);
  5. if ($odd_even % 2) {
  6. $class = 'odd';
  7. } else {
  8. $class = 'even';
  9. }
  10. $content .= '<li class="'.$class.'">';
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.