#40730 [NEW]: Array sequence corrupted when elements are added with double digit indexes

From: Date: Mon, 05 Mar 2007 14:55:30 +0000
Subject: #40730 [NEW]: Array sequence corrupted when elements are added with double digit indexes
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-109926@lists.php.net to get a copy of this message
From: slawo_c at o2 dot pl Operating system: Mac OS X 10.4.8 PHP version: 5.2.1 PHP Bug Type: Arrays related Bug description: Array sequence corrupted when elements are added with double digit indexes Description: ------------ When I create an array using the following code the array is corrupted for some reason, as if the double digits were misinterpreted or misread at some point. From my experience it happens specifically on index 08 and 09 (which are set to 0) Even if the order is different. The consequence is that data with index 08 will be overwritten by 09 or 09 will be overwritten by 08 if 08 is set after 09. Example code: Reproduce code: --------------- $list = array(); $list[01]='a'; $list[02]='b'; $list[03]='c'; $list[04]='d'; $list[05]='da'; $list[06]='db'; $list[07]='dc'; $list[08]='e'; $list[09]='ea'; $list[10]='eb'; $list[11]='ec'; $list[12]='f'; echo '<pre>'; var_dump($list); echo '</pre>'; Expected result: ---------------- array(11) { [1]=> string(1) "a" [2]=> string(1) "b" [3]=> string(1) "c" [4]=> string(1) "d" [5]=> string(2) "da" [6]=> string(2) "db" [7]=> string(2) "dc" [8]=> string(2) "e" [9]=> string(2) "ea" [10]=> string(2) "eb" [11]=> string(2) "ec" [12]=> string(1) "f" } Actual result: -------------- array(11) { [1]=> string(1) "a" [2]=> string(1) "b" [3]=> string(1) "c" [4]=> string(1) "d" [5]=> string(2) "da" [6]=> string(2) "db" [7]=> string(2) "dc" [0]=> string(2) "ea" //<- Here 09 overwrote 08 which was also set to 0 by the parser/interpreter? [10]=> string(2) "eb" [11]=> string(2) "ec" [12]=> string(1) "f" } -- Edit bug report at http://bugs.php.net/?id=40730&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40730&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40730&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40730&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40730&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40730&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40730&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40730&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40730&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40730&r=support Expected behavior: http://bugs.php.net/fix.php?id=40730&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40730&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40730&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40730&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40730&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40730&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40730&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40730&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40730&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40730&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40730&r=mysqlcfg

« previous php.bugs (#109926) next »