Um bom exemplo de uso pode ser o famoso cor sim cor não das tabelas, mas com essa função você pode dar mais um "tchan", colocar cor 1, cor 2, cor 3, etc.
Igual o que o orkut usa
<?
function cycle($itens) {
static $last_key;
static $last_itens;
$cycle = preg_split('/[,;\s]+/', $itens);
if (is_null($last_itens) or $itens != $last_itens) {
$last_itens = $itens;
$last_key = 0;
}
else {
$key = $last_key;
if($key == (count($cycle)-1)) {
$last_key = 0;
}
else {
$last_key = $key + 1;
}
}
return $cycle[$last_key];
}
// para usar
for($i = 0; $i < 10; $i++) {
echo '<div style="background-color: '.cycle("red;blue;green;yellow").';">Teste das cores</div><br />';
}
?>
Fonte:
http://www.babooforum.com.br