Re: Looping through arrays with foreach
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Looping through arrays with foreach

From: chernyshevsky@hotmail.com <chernyshevsky@hotmail-dot-com.no-spam.invalid>
Date: Fri Mar 31 2006 - 22:39:46 CEST

Sjoerd wrote:
> Another method to loop through an array is the following:
> ?php
> while (list(, $value) = each($arr)) {
> echo "Value: $value<br />\n";
> }
> ?
>
The main problem with the list() = each() construct is that it has a
side-effect--namely that of advancing the array's internal pointer.
Forgetting to call reset() on an array was a common mistake in PHP 3.
Received on Mon May 1 02:45:55 2006