note 30013 deleted from function.array-shift by nlopess

From: Date: Thu, 07 Sep 2006 14:59:38 +0000
Subject: note 30013 deleted from function.array-shift by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116837@lists.php.net to get a copy of this message
Note Submitter: archangel at uro dot mine dot nu ---- 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.

« previous php.notes (#116837) next »