note 23767 added to function.next
| From: | michael at sitecross_dot_com dot php dot net | Date: | Sat, 27 Jul 2002 19:15:27 +0000 |
| Subject: | note 23767 added to function.next | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-33704@lists.php.net to get a copy of this message | ||
This example will start with the *second* entry because of the initial call to next().
$colorList=array("#FFFFFF","#F1F2E6","#CCCCCC");
for(..) {
..
$color = (next($colorList)) ? current($colorList) : reset($colorList);
..
}
Here is an example that will start with the first entry.
$colorList=array("#FFFFFF","#F1F2E6","#CCCCCC");
for(..) {
..
$color = current($colorList);
if(!next($colorList)){
reset($colorList);
}
..
}
It takes a little more code, but if you need the first entry to come up first or are a stickler for
details like me, then you will need something like it.
--
http://www.php.net/manual/en/function.next.php
http://master.php.net/manage/user-notes.php?action=edit+23767
http://master.php.net/manage/user-notes.php?action=delete+23767
http://master.php.net/manage/user-notes.php?action=reject+23767