From: [EMAIL PROTECTED] Operating system: SuSE 7.2 PHP version: 4.3.0 PHP Bug Type: Arrays related Bug description: Array keys like "-123" are not turned into ints
A string which would evaluate to a negative integer (such as "-123") will not be turned into an integer when used as an array key. I don't recall seeing anywhere an explicit explanation of how strings are treated when used as array keys, but obviously those strings that are valid representations of non-negative integers are implicitly treated as integers, and everything else is seen as strings. I think it would make sense to extend this to _all_ valid integers, as the behavior in this example is not quite what one would expect: $arr = array(-1 => "a", 0 => "b", 1 => "c"); $arr["-1"] = "e"; $arr["0"] = "f"; $arr["1"] = "g"; print_r($arr); echo "\n"; var_dump($arr); -- Edit bug report at http://bugs.php.net/?id=22201&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=22201&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=22201&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=22201&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=22201&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=22201&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=22201&r=support Expected behavior: http://bugs.php.net/fix.php?id=22201&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=22201&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=22201&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=22201&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22201&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=22201&r=dst IIS Stability: http://bugs.php.net/fix.php?id=22201&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=22201&r=gnused
