ID:               43559
 Updated by:       [EMAIL PROTECTED]
 Reported By:      kraghuba at in dot ibm dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Arrays related
 Operating System: Linux, windows
 PHP Version:      5.2CVS-2007-12-11 (snap)
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2008-01-23 09:59:41] [EMAIL PROTECTED]

The .phpt also fixed:

http://ecl.zoone.com.br/etc/patches/array_merge_recursive_variation5.patch

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

[2008-01-23 00:35:52] [EMAIL PROTECTED]

Looks fine to me.

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

[2008-01-17 21:35:13] [EMAIL PROTECTED]

Simple fix:
http://ecl.zoone.com.br/etc/patches/bug43559.patch

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

[2007-12-11 05:35:05] kraghuba at in dot ibm dot com

Description:
------------
When two arrays having common key and value are passed as argument to
array_merge_recursive(), the function behaves in an unexpected way for
NULL values. It outputs an empty array instead of an array having two
elements, both being NULL. Whereas, the function behaves in an expected
way with values other than NULL. This behavior can be observed in the
testcase array_merge_recursive_variation9.phpt.
   
This behavior is observed in PHP5.3 and PHP6 as well.

I tried creating an array with two null values and it works:
  <?php
  $a = array(NULL, NULL);
  var_dump($a);
  ?>
output:
  array(2) {
  [0]=>
  NULL
  [1]=>
  NULL
}




Reproduce code:
---------------
<?php
$a1 = array( 'b' => 'string' );
$a2 = array( 'b' => 'string' );
$a3 = array( 'b' => NULL );
$a4 = array( 'b' => NULL );
var_dump( array_merge_recursive($a1, $a2) );  // expected output
var_dump( array_merge_recursive($a3, $a4) );  // unexpecteed output
?>


Expected result:
----------------
array(1) {
  ["b"]=>
  array(2) {
    [0]=>
    string(6) "string"
    [1]=>
    string(6) "string"
  }
}
array(1) {
  ["b"]=>
  array(2) {
    [0]=>
    NULL
    [1]=>
    NULL
  }
}


Actual result:
--------------
array(1) {
  ["b"]=>
  array(2) {
    [0]=>
    string(6) "string"
    [1]=>
    string(6) "string"
  }
}
array(1) {
  ["b"]=>
  array(0) {
  }
}



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


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

Reply via email to