php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55549 Key type changes in array with custom key
Submitted: 2011-08-31 09:08 UTC Modified: 2011-08-31 11:15 UTC
From: eduardo at alonsoalbella dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.3.8 OS: Linux
Private report: No CVE-ID: None
 [2011-08-31 09:08 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-31 11:15 UTC] laruence@php.net
-Status: Open +Status: Bogus
 [2011-08-31 11:15 UTC] laruence@php.net
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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 09:01:27 2024 UTC