Re: PHP 4.0 Bug #5704: two nested foreach loops on the same array stop prematurely.

From: Date: Thu, 20 Jul 2000 18:20:34 +0000
Subject: Re: PHP 4.0 Bug #5704: two nested foreach loops on the same array stop prematurely.
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-25269@lists.php.net to get a copy of this message
Hi bailey! On Thu, 20 Jul 2000, bailey@mcs.anl.gov wrote: > From: bailey@mcs.anl.gov > Operating system: Redhat Linux 6.1, kernel 2.2.15 > PHP version: 4.0.0 > PHP Bug Type: Misbehaving function > Bug description: two nested foreach loops on the same array stop prematurely. > > <?php > > $config = array( 1 => "foo", > 2 => "bar", > 3 => "far", > ); > > foreach ($config as $resource => $value) { > echo $resource, ":<br>\n"; + reset ($config); // see below > foreach ($config as $resource2 => $value2) { > echo "$resource2<br>\n"; > } > } > > ?> > This is a rather severe error, I think. I think there were some talks if the internal array pointer should be reseted or not some while ago. If you reset it manually, like above you will get the desired behaviour. I think it's a feature, not a bug and the report should be closed. -- teodor

« previous php.dev (#25269) next »