archangel at uro dot mine dot nu
04-Mar-2003 06:11
Here's a fun little trick for cycling a set of items in the case where you
want to say loop thorugh a set of styles for a tiled
effect:
<?php
$styles = array('style1', 'style2', 'style3',
... 'stylen');
while (haveMoreToPrint())
{
array_push($styles, array_shift($styles));
print('<div
class="'.$styles[0].'">Some
content</div>');
}
?>
And since the elements that
are being shifted off go onto the end, there is no concern as to how many
or how few styles your have or how many times you are going to cycle
through them. No counters, no nothin.