|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-01-17 21:35 UTC] felipe@php.net
[2008-01-23 00:35 UTC] andrei@php.net
[2008-01-23 09:59 UTC] felipe@php.net
[2008-01-23 12:06 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 10:00:01 2025 UTC |
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) { } }