note 19408 modified in control-structures.while by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 13:55:18 +0000 |
| Subject: | note 19408 modified in control-structures.while by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79835@lists.php.net to get a copy of this message | ||
At the end of the while (list / each) loop the array pointer will be at the end.
This means the second while loop on that array will be skipped!
You can put the array pointer back with the reset($myArray) function.
example:
<?php
$myArray=array('aa','bb','cc','dd');
while (list ($key, $val) = each ($myArray) ) echo $val;
reset($myArray);
while (list ($key, $val) = each ($myArray) ) echo $val;
?>
--was--
At the end of the while (list / each) loop the array pointer will be at the end.
This means the second while loop on that array will be skipped!
You can put the array pointer back with the reset($myArray) function.
example:
$myArray=array('aa','bb','cc','dd');
while (list ($key, $val) = each ($myArray) ) echo $val;
reset($myArray);
while (list ($key, $val) = each ($myArray) ) echo $val;
http://php.net/manual/en/control-structures.while.php