|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9307 Numeric-looking array keys are forced to be integers
Submitted: 2001-02-16 16:17 UTC Modified: 2001-03-06 08:24 UTC
From: Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.4pl1 OS: Linux
Private report: No CVE-ID: None
 [2001-02-16 16:17 UTC]
$myarray['105'] = 'Hello';
$myarray[(string)'106'] = 'Goodbye';

array(2) {
  string(5) "Hello"
  string(7) "Goodbye"

It shouldn't be auto-converting array keys to numbers if they're already of a different type! Let's say I have an whole list of items as my array keys, and one just happens to be "able" to be converted into a number. Suddenly one of my array keys is no longer a string.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-06 08:24 UTC]
Right, this is how PHP works. That's not a bug, that's an
intended behaviour.
 [2010-03-31 12:22 UTC] info at fedushin dot ru
Some arguments to consider (integer)1 and "1" as different array keys are given in Bug #51384.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Nov 29 11:05:56 2022 UTC