/ Published in: PHP
Expand |
Embed | Plain Text
function cycle(/*$val1, $val2, $valN*/) { if ($length == 0) { $counter = 0; return null; } return $values[$counter++ % $length]; } // example usage $i = 0; while ($i++ < 5) { } cycle(); // reset $i = 0; while ($i++ < 6) { } /* output => odd even odd even odd a b c d a b */
You need to login to post a comment.
