Bug #55135 [NEW]: Array keys are no longer type casted in unset()

From: Date: Tue, 05 Jul 2011 13:23:19 +0000
Subject: Bug #55135 [NEW]: Array keys are no longer type casted in unset()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-161591@lists.php.net to get a copy of this message
From: Operating system: Linux PHP version: 5.4SVN-2011-07-05 (SVN) Package: Scripting Engine problem Bug Type: Bug Bug description:Array keys are no longer type casted in unset() Description: ------------ An array key passed to unset() from a variable doesn't seem to be typecasted anymore. Test script: --------------- This doesn't work anymore in PHP 5.4: <?php // This fails. $array = array(1 => 2); $a = "1"; unset($array[$a]); print_r($array); // Those works. $array = array(1 => 2); $a = 1; unset($array[$a]); print_r($array); $array = array(1 => 2); unset($array[1]); print_r($array); $array = array(1 => 2); $a = 1; unset($array["1"]); print_r($array); ?> Expected result: ---------------- Array ( ) Array ( ) Array ( ) Array ( ) Actual result: -------------- Array ( [1] => 2 ) Array ( ) Array ( ) Array ( ) -- Edit bug report at https://bugs.php.net/bug.php?id=55135&edit=1 -- Try a snapshot (PHP 5.2): https://bugs.php.net/fix.php?id=55135&r=trysnapshot52 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55135&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55135&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55135&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55135&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55135&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55135&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55135&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55135&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55135&r=support Expected behavior: https://bugs.php.net/fix.php?id=55135&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55135&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55135&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55135&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55135&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55135&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55135&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55135&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55135&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55135&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55135&r=mysqlcfg Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55135&r=trysnapshot54

« previous php.bugs (#161591) next »