Just thinking if using code like this
<?php
abstract class helper
{
private static $_cycles = array();
public static function isOdd($v)
{
return (0 == ($v % 2)) ? false: true;
}
public static function isEven($v)
{
return !self::isOdd($v);
}
public static function cycle($odd, $even)
{
$trace = debug_backtrace();
$trace = $trace[0];
$cycle = crc32(serialize($trace));
if (!isset(self::$_cycles[$cycle]))
{
self::$_cycles[$cycle] = 1;
}
return (self::isOdd(self::$_cycles[$cycle]++)) ? $odd : $even;
}
}
for featues like this
<?php foreach ($data as $record): ?>
<p class="<?php echo helper::cycle('oddCss', 'evenCss'); ?>"><?php echo $record; ?></p>
<?php endforeach; ?>
is not overcoded
PS
Easy of usage (by html/css coders) is more important then performance in this particular case
UPDATE:
As @Geoffrey mentioned i didn't tell before that same 'oddCss', 'evenCss' pair may be used several times on one page (so basically within one request)