This is a quick and dirty method to get the infamous “Zebra Strips” on tables by assigning alternating classes.
For this example we’ll use the fmod() function in PHP…
<?php
$j = 1;
foreach ($newsletters as $key)
{
$name = (fmod($j++, 2)) ? 'even' : 'odd';
echo '‘
.’ some date ‘
.’ some title and links ‘
.’ some more stuff ‘
.’ ‘;
}
?>


0 Responses to “Odds or Even in PHP”