Bug #55135 [Opn->Asn]: Array keys are no longer type casted in unset()
| From: | johannes@php.net | Date: | Tue, 05 Jul 2011 18:58:38 +0000 |
| Subject: | Bug #55135 [Opn->Asn]: Array keys are no longer type casted in unset() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-161601@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55135&edit=1
ID: 55135
Updated by: johannes@php.net
Reported by: damien at commerceguys dot com
Summary: Array keys are no longer type casted in unset()
-Status: Open
+Status: Assigned
Type: Bug
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 5.4SVN-2011-07-05 (SVN)
-Assigned To:
+Assigned To: dmitry
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2011-07-05 09:23:18] damien at commerceguys dot com
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 this bug report at https://bugs.php.net/bug.php?id=55135&edit=1