php shorthand if/else odd/even div class loop
$count = 0;
foreach($posts as $post) {
//odd & even styling
$oe_style = ++$count % 2 ? "odd" : "even";
//or
echo '<div class="' . (++$count % 2 ? "odd" : "even") . '">';
}
Written by Wayne Roddy
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#