Edit report at https://bugs.php.net/bug.php?id=55135&edit=1

 ID:                 55135
 Updated by:         johan...@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

Reply via email to