Re: Foreach problem.

From: Date: Fri, 11 Feb 2005 03:18:59 +0000
Subject: Re: Foreach problem.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-208507@lists.php.net to get a copy of this message
On 10 Feb 2005 Richard Lynch wrote: > Perhaps you need to use http://php.net/reset > > You see, when you do foreach or each or any of those, there is an > "internal" setting in the array that is altered to keep track of where you > are. Kind of like a big "You are here" arrow inside the guts of the > array. I believe this is incorrect. Or if not, the docs are wrong. From http://www.php.net/manual/en/control-structures.foreach.php: Note: When foreach first starts executing, the internal array pointer is automatically reset to the first element of the array. This means that you do not need to call reset() before a foreach loop. I don't know why the original poster had a problem, it seems mysterious so far, but it seems it probably wasn't for lack of a reset() call. -- Tom

« previous php.general (#208507) next »