Forum Moderators: coopster
$color[0] = "row1";
$color[1] = "row2";
$a = 4;
echo $color[$a%2] . "<br>";
$a = 3;
echo $color[$a%2] . "<br>";
or define your own little function:
function color ($c1, $c2, $index) {
if ($index%2 == 0)
return ($c1);
else
return ($c2);
}
echo color ("row1", "row2", 4) . "<br>";
echo color ("row1", "row2", 3) . "<br>";
have fun,
nerd
I usually check for an integer with the count in the loop:
$count = 0;foreach ($blah as $something)
{if (is_int($count++/2))
{
$color="row1";
}else{
$color="row2";
}}
Something simple like that should work ok. So, each time the count increments, the division will be an integer, then it won`t, then it will...etc
dc