View Single Post
Old 11-17-2008, 11:36 AM   #2 (permalink)
Measter
The Wanderer
 
Join Date: Nov 2008
Location: Plymouth, UK
Posts: 9
Thanks: 0
Measter is on a distinguished road
Default

You would flip a variable every time the loop is run. For example:

PHP Code:
$flipper false;

foreach(
$array as $something)
  {
    
$flipper = !$flipper;
    
    
$echo '<div class="someclass' . (int)$flipper '">some text</div>';
  } 
Basicly, if $fipper is false, you'll end up with the class being 'someclass0', and if $flipper is true, you'll end up with 'someclass1'. The joys of typecasting.
Measter is offline  
Reply With Quote