Bug #15340: foreach doesnt reset object arrays

From: Date: Sat, 02 Feb 2002 08:19:18 +0000
Subject: Bug #15340: foreach doesnt reset object arrays
Groups: php.dev 
Request: Send a blank email to php-dev+get-78845@lists.php.net to get a copy of this message
From: advGraph@regiocom.net Operating system: Windows 2000 PHP version: 4.1.1 PHP Bug Type: Arrays related Bug description: foreach doesnt reset object arrays Using reset on an array of objects seems to alter the array counters of the object's arrays, even though foreach is not dealing with that array. Then, as foreach is supposed to, it doesnt reset them. Example: class child{ var $items = array("A1", "A2", "A3"); } $arr=array(new child, new child, new child); print "step1<br>"; print sizeof($arr)."<br>"; foreach($arr as $v) print $v->items[0]."<br>"; // Three A1 printed print "<hr>step2<br>"; print sizeof($arr)."<br>"; foreach($arr as $v) print $v[1]."<br>"; // No A1 printed -- Edit bug report at: http://bugs.php.net/?id=15340&edit=1 Fixed in CVS: http://bugs.php.net/fix.php?id=15340&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=15340&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=15340&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=15340&r=oldversion Not for support: http://bugs.php.net/fix.php?id=15340&r=support Not wrong behavior: http://bugs.php.net/fix.php?id=15340&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=15340&r=notenoughinfo

« previous php.dev (#78845) next »