note 43462 added to function.array-merge-recursive

From: Date: Tue, 22 Jun 2004 11:30:43 +0000
Subject: note 43462 added to function.array-merge-recursive
Groups: php.notes 
Request: Send a blank email to php-notes+get-71490@lists.php.net to get a copy of this message
Please be aware that under circumstances where you have both the key and value common between the two arrays at a given node, array_merge_recursive() will behave differently if that value is NULL, as opposed to a non-null value. i.e., I expected the results of the first two sections below to have the same structure, but they don't. If this might apply to you, please see for yourself. <pre><?php $a1 = array('a'=>'b'); $a2 = array('a'=>'b'); $a3 = array_merge_recursive($a1,$a2); var_export($a3); echo "\n\n"; $a1 = array('a'=>NULL); $a2 = array('a'=>NULL); $a3 = array_merge_recursive($a1,$a2); var_export($a3); echo "\n\n"; $a1 = array('a'=>'b'); $a2 = array('a'=>NULL); $a3 = array_merge_recursive($a1,$a2); var_export($a3); echo "\n\n"; ?></pre> This behavior also occurs if the value is the empty array. In fact, in the above example, interchanging the empty array with any and all occurences of NULL will yield the same result. code till dawn! -mark ---- Manual Page -- http://www.php.net/manual/en/function.array-merge-recursive.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43462 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43462&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43462&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#71490) next »