From: black at scene-si dot org Operating system: linux debian PHP version: 4.3.2 PHP Bug Type: Scripting Engine problem Bug description: key() in for loop "breaks" ?
Description: ------------ replace key() with current() and you get the value with no problems, key() however doesnt work. the wierd part, sometimes the bellow code works, since i have 2 "identical" classes, one of which uses this method with key() - and makes correct results, however this short reproducable script doesnt. works: http://sunshine.krneki.org/files/halcyon/hal.phps doesnt: http://sunshine.krneki.org/files/halcyon/hal2.phps (search for 'reset', note that i have changed to use current in hal2.phps in the update function, so check out plot() which is still identical). cleaning up code is sometimes a b***h ;) Reproduce code: --------------- $data = array("foo","bar","x","y"); for (reset($data); $id=key($data); next($data)) { var_dump($id); } for (reset($data); $id=current($data); next($data)) { var_dump($id); } Expected result: ---------------- int(0) int(1) int(2) int(3) string(3) "foo" string(3) "bar" string(1) "x" string(1) "y" Actual result: -------------- string(3) "foo" string(3) "bar" string(1) "x" string(1) "y" -- Edit bug report at http://bugs.php.net/?id=24539&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24539&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24539&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=24539&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24539&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24539&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24539&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24539&r=support Expected behavior: http://bugs.php.net/fix.php?id=24539&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24539&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24539&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24539&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24539&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24539&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24539&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24539&r=gnused