note 88051 added to control-structures.for
| From: | dkimbel13 at gmail dot com | Date: | Wed, 07 Jan 2009 23:41:46 +0000 |
| Subject: | note 88051 added to control-structures.for | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148929@lists.php.net to get a copy of this message | ||
Just a note on looping through an array using the for() loop.
with the array...
$array = array("value1","value2","value3");
then...
for(reset($array),current($array),next($array){
echo("Element ".key($array)." contains
".current($array)."<br/>";
}
is the equivalent of...
for($i=0;$i<count($array);$i++){
echo("Element $i contains $array[$i]<br/>");
}
I don't know if there is any advantage, just thought I would mention it.
----
Server IP: 208.69.120.35
Probable Submitter: 209.165.147.99
----
Manual Page -- http://www.php.net/manual/en/control-structures.for.php
Edit -- https://master.php.net/note/edit/88051
Del: integrated -- https://master.php.net/note/delete/88051/integrated
Del: useless -- https://master.php.net/note/delete/88051/useless
Del: bad code -- https://master.php.net/note/delete/88051/bad+code
Del: spam -- https://master.php.net/note/delete/88051/spam
Del: non-english -- https://master.php.net/note/delete/88051/non-english
Del: in docs -- https://master.php.net/note/delete/88051/in+docs
Del: other reasons-- https://master.php.net/note/delete/88051
Reject -- https://master.php.net/note/reject/88051
Search -- https://master.php.net/manage/user-notes.php