ID: 46154
User updated by: akam at akameng dot com
Reported By: akam at akameng dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Windows XP SP2
PHP Version: 5.2.6
New Comment:
Actual result:
--------------
php.net
php.net
php.net
$key = zero and $value = php.net
$key = and $value = php.net
Previous Comments:
------------------------------------------------------------------------
[2008-09-22 20:50:32] akam at akameng dot com
Description:
------------
due to this line of php manual:
"Using the empty string as a key will create (or overwrite) a key
with the empty string and its value;"
but empty string key will work.
Reproduce code:
---------------
<?php
$test = array('zero' => 'php.net', '' => 'php.net', "" => 'php.net' );
//test
echo $test['zero']."\n<br />"; //output: php.net
echo $test['']."\n<br />"; //output: php.net
echo $test[""]."\n<br />"; //output: php.net
foreach ($test as $key => $value ){
echo "\$key = $key and \$value = $value \n<br />";
}
//out put
/*
$key = zero and $value = php.net
$key = and $value = php.net
*/
?>
Expected result:
----------------
php.net
php.net
Actual result:
--------------
php.net
php.net
php.net
php.net
php.net
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46154&edit=1