Edit report at https://bugs.php.net/bug.php?id=54140&edit=1

 ID:                 54140
 Comment by:         siedler1 at freenet dot de
 Reported by:        forjest at gmail dot com
 Summary:            array_merge() break keys during merge
 Status:             Open
 Type:               Bug
 Package:            Arrays related
 Operating System:   *Nix
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

I have php version 5.3.6 on Ubuntu and this behavior still exist.


Previous Comments:
------------------------------------------------------------------------
[2011-04-20 17:09:29] martin at fleveo dot cz

This bug is on Windows 7 too (same version of PHP).

------------------------------------------------------------------------
[2011-03-09 19:27:38] cybd at bigmir dot net

Maybe, simpler example.

OK:
    $c = array('01'=>3, '03'=>10);
    $d = array('05'=>44, '07'=>3);

    var_dump(array_merge($c,$d));

Failed:
    $a = array('01'=>1, '02'=>73);
    $b = array('10'=>11, '11'=>23);
    
    var_dump(array_merge($a,$b));

------------------------------------------------------------------------
[2011-03-02 19:03:46] forjest at gmail dot com

Works as expected on Windows platform.

------------------------------------------------------------------------
[2011-03-02 18:21:06] forjest at gmail dot com

Description:
------------
array_merge interprets string keys, containing only digits as numeric keys, if 
numeric overflow not reached.

String keys should works as strings regarless of their contents.


Test script:
---------------
var_dump(array_merge(array('t777'=> array("I'm a string"))));
var_dump(array_merge(array("42424242"=> array("I'm a string of digits"))));
var_dump(array_merge(array("777777777777777777777777777777777777777777777777777777777"=>
 array("I'm string of digits too"))));

var_dump(is_string("42424242"));
var_dump(is_string(42424242));
var_dump(is_string("777777777777777777777777777777777777777777777777777777777"));


Expected result:
----------------
array(1) {
  ["t777"]=>
  array(1) {
    [0]=>
    string(12) "I'm a string"
  }
}
array(1) {
  ["42424242"]=>
  array(1) {
    [0]=>
    string(22) "I'm a string of digits"
  }
}
array(1) {
  ["777777777777777777777777777777777777777777777777777777777"]=>
  array(1) {
    [0]=>
    string(24) "I'm string of digits too"
  }
}
bool(true)
bool(false)
bool(true)

Actual result:
--------------
array(1) {
  ["t777"]=>
  array(1) {
    [0]=>
    string(12) "I'm a string"
  }
}
array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(22) "I'm a string of digits"
  }
}
array(1) {
  ["777777777777777777777777777777777777777777777777777777777"]=>
  array(1) {
    [0]=>
    string(24) "I'm string of digits too"
  }
}
bool(true)
bool(false)
bool(true)


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=54140&edit=1

Reply via email to