php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51567 numerically indexed php arrays bug
Submitted: 2010-04-16 01:41 UTC Modified: 2010-04-16 06:13 UTC
From: msbullshit at hotmail dot com Assigned:
Status: Not a bug Package: *XML functions
PHP Version: 5.3.2 OS: OSX, FreeBSD
Private report: No CVE-ID: None
 [2010-04-16 01:41 UTC] msbullshit at hotmail dot com
Description:
------------
Many people have complained about the indexed array bug already. Will this bug 
ever be fixed?

The keys are lost if they have a numeric value even if they are set to type 
string.

There was said that it wont be fixed:
http://bugs.php.net/21949
http://bugs.php.net/37746

There was said that it was fixed:
http://bugs.php.net/50285
http://phpxmlrpc.sourceforge.net/news.html

However it wasn't fixed. I still have the problem on PHP 5.3.1.

Test script:
---------------
<?
$a=array(1=>'one', '3'=>'three', 5=>'five', 'a'=>'foo');
print_r($a);
print_r(xmlrpc_decode(xmlrpc_encode($a)));
?>

Expected result:
----------------
Array
(
    [1] => one
    [3] => three
    [5] => five
    [a] => foo
)
Array
(
    [1] => one
    [3] => three
    [5] => five
    [a] => foo
)

Actual result:
--------------
Array
(
    [1] => one
    [3] => three
    [5] => five
    [a] => foo
)
Array
(
    [0] => one
    [1] => three
    [2] => five
    [a] => foo
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-16 06:11 UTC] rasmus@php.net
-Status: Open +Status: Bogus
 [2010-04-16 06:11 UTC] rasmus@php.net
You are not using PHP-5.3.2 then.  This was fixed in that version.  Just verified 
it here.
 [2010-04-16 06:13 UTC] rasmus@php.net
Ah, I see in the body of your report you say 5.3.1, but you have 5.3.2 in the 
header.  So yes, this was fixed in 5.3.2 as stated in the Changelog 
http://www.php.net/ChangeLog-5.php#5.3.2
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Dec 05 15:05:52 2022 UTC