2009
12.19
12.19
There are dozens of ways to alternate. The most common and visible is the background colour of your tabular data. I use PHP to generate my HTML and the following are my two favourites:
foreach( (array)$results AS $K => $V )
{$alt = ( $alt == ‘odd’ ) ? ‘even’ : ‘odd’ ;}
This works well for in iteration variable. But, what if you’ve got something declared before this loop and you don’t want to ask for that same declaration over and over. ( Lack of speed kills. )
$i = 0 ;
foreach( (array)$results AS $K => $V )
{
$alt = ( eregi( “\.” , ( $i / 2 ) ) ) ? ‘even’ : ‘odd’ ;
$i++;
}