Bug #55549 [Opn->Bgs]: Key type changes in array with custom key
| From: | laruence@php.net | Date: | Wed, 31 Aug 2011 11:15:39 +0000 |
| Subject: | Bug #55549 [Opn->Bgs]: Key type changes in array with custom key | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-163186@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55549&edit=1
ID: 55549
Updated by: laruence@php.net
Reported by: eduardo at alonsoalbella dot com
Summary: Key type changes in array with custom key
-Status: Open
+Status: Bogus
Type: Bug
Package: Arrays related
Operating System: Linux
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2011-08-31 09:08:29] eduardo at alonsoalbella dot com
Description:
------------
The bug is very simple, if you create an array with a custom key, if it detects that the key might
be an integer, it will cast that key to an integer automatically.
(You have an example below)
Test script:
---------------
<?php
$key1 = "00";
$key2 = "01";
$key3 = "11";
$array[$key1] = '';
$array[$key2] = '';
$array[$key3] = '';
foreach($array as $key => $value)
{
echo $key.':'.gettype($key).'<br />';
}
?>
Expected result:
----------------
00:string
01:string
11:string
Actual result:
--------------
00:string
01:string
11:integer
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55549&edit=1