Bug #75328 [NEW]: Unable to typecast numeric array key to string

From: Date: Fri, 06 Oct 2017 17:40:18 +0000
Subject: Bug #75328 [NEW]: Unable to typecast numeric array key to string
Groups: php.standards 
Request: Send a blank email to standards-+get-1297@lists.php.net to get a copy of this message
From: langebroek at gmail dot com Operating system: Any PHP version: Irrelevant Package: PHP Language Specification Bug Type: Bug Bug description:Unable to typecast numeric array key to string Description: ------------ Rather self explanatory; it seems impossible to have a numeric string as an array key. For the project I'm working on this is almost a necessity. Test script: --------------- $buf=array((string)1=>'x',"2"=>'y','3'=>'z'); #var_dump($buf);//all int var_dump(array_keys($buf));//clarify all int Expected result: ---------------- In at least one case I'd expect to see a string in the array key, or have an alternative method to achieve such. In some cases it is unwise to typecast at a later time. Actual result: -------------- array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } -- Edit bug report at https://bugs.php.net/bug.php?id=75328&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75328&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75328&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75328&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75328&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75328&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75328&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75328&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75328&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75328&r=support Expected behavior: https://bugs.php.net/fix.php?id=75328&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75328&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75328&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75328&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75328&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75328&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75328&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75328&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75328&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75328&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75328&r=mysqlcfg

« previous php.standards (#1297) next »