Doc #60661 [NEW]: array_shift converts string-encapsulated numbers into numbers

From: Date: Wed, 04 Jan 2012 22:24:43 +0000
Subject: Doc #60661 [NEW]: array_shift converts string-encapsulated numbers into numbers
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7730@lists.php.net to get a copy of this message
From: Operating system: PHP version: 5.3.8 Package: Arrays related Bug Type: Documentation Problem Bug description:array_shift converts string-encapsulated numbers into numbers Description: ------------ --- From manual page: http://www.php.net/function.array-shift#refsect1-function.array-shift-seealso --- Having an associative array where the keys are number-strings (enclosed in quotes as strings - see example), this strings get converted into numbers when using array_shift(). This is a severe bug! Test script: --------------- $a["_"] = "blank dummy"; $a["01"] = "one"; $a["10"] = "ten"; $a["20"] = "twenty"; print_r( $a ); echo $a["10"] . "\n"; array_shift( $a ); print_r( $a ); echo $a["10"] . "\n"; // THIS PRODUCES AN UNDEFINED INDEX ERROR echo $a["20"] . "\n"; // THIS PRODUCES AN UNDEFINED INDEX ERROR echo $a[0] . "\n"; // THIS SHOULD PRODUCE AN ERROR BUT SHOWS THE VALUE echo $a[1] . "\n"; // THIS SHOULD PRODUCE AN ERROR BUT SHOWS THE VALUE Expected result: ---------------- I expect that the line echo $a["10"] . "\n"; will produce "ten" as an output, also echo $a["20"] . "\n"; should output "twenty". Actual result: -------------- Notice: Undefined index: 10 in [test] on line 13 -- Edit bug report at https://bugs.php.net/bug.php?id=60661&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60661&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60661&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60661&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60661&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60661&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60661&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60661&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60661&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60661&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60661&r=support Expected behavior: https://bugs.php.net/fix.php?id=60661&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60661&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60661&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60661&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60661&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60661&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60661&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60661&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60661&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60661&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60661&r=mysqlcfg

« previous php.doc.bugs (#7730) next »