Bug #16227 Updated: nested while(list = each) break, weird workaround

From: Date: Sat, 23 Mar 2002 01:19:56 +0000
Subject: Bug #16227 Updated: nested while(list = each) break, weird workaround
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-3177@lists.php.net to get a copy of this message
ID: 16227 Updated by: yohgaki@php.net Reported By: php.net@alienbill.com -Status: Open +Status: Analyzed Bug Type: Arrays related Operating System: Linux -PHP Version: 4.1.2 +PHP Version: 4.2.0-dev New Comment: Thanks for reporting. I verified with 4.2.0-dev & 4.0.6. This is _VERY_ bad bug... [root@dev etc]# php <?php $outsidearray = array("key1","key2"); $insidearray = array("0","1"); while(list(,$outerval) = each($outsidearray)){ //$placeholder = $insidearray; while(list(,$innerval) = each($insidearray)){ print "inloop $innerval for $outerval<br>"; } } ?> inloop 0 for key1<br> inloop 1 for key1<br> [root@dev etc]# php <?php $outsidearray = array("key1","key2"); $insidearray = array("0","1"); while(list(,$outerval) = each($outsidearray)){ $placeholder = $insidearray; while(list(,$innerval) = each($insidearray)){ print "inloop $innerval for $outerval<br>"; } } ?> inloop 0 for key1<br> inloop 1 for key1<br> inloop 0 for key2<br> inloop 1 for key2<br> [root@dev etc]# [root@dev etc]# php -v 4.2.0-dev Previous Comments: ------------------------------------------------------------------------ [2002-03-22 19:52:31] php.net@alienbill.com nested while(list=each) produces weird results. this code <?php $outsidearray = array("key1","key2"); $insidearray = array("0","1"); while(list(,$outerval) = each($outsidearray)){ //$placeholder = $insidearray; while(list(,$innerval) = each($insidearray)){ print "inloop $innerval for $outerval<br>"; } } ?> only gets to key1 of the outer loop. But if you uncomment the $placeholder line, it works ok. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16227&edit=1

« previous php.bugs (#3177) next »