ID: 25494 Updated by: [EMAIL PROTECTED] Reported By: enygma at phpdeveloper dot org -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Red Hat Linux PHP Version: 4.3.2 New Comment:
If you use var_dump() in place of print_r(), you'd see that it's not a mysterious value, it's 'false'. The boolean value is being converted to an array index in array_merge(). (Any value would produce similar results -- $array1=4; would produce an array value of $last_array[0]==4.) array_intersect() does a type check before it does anything, which is why the warning comes up. While it seems inconsistent, I can't see this being changed because it would affect BC (albeit BC on a somewhat obscure, undocumented feature). Somebody correct me here if I'm wrong. So I'm bogusing it for now. J Previous Comments: ------------------------------------------------------------------------ [2003-09-11 11:42:19] [EMAIL PROTECTED] 1. Please use var_dump() instead of print_r() 2. The value in the merged array is (bool) false ------------------------------------------------------------------------ [2003-09-11 10:59:27] enygma at phpdeveloper dot org array_merge_recursive() shows the same behavior array_intersect(), however, doesn't and gives a correct warning message ------------------------------------------------------------------------ [2003-09-11 10:57:27] enygma at phpdeveloper dot org Description: ------------ Code: --------------------------------------- $array1=false; $array2=array("test"=>"1","testing"=>"2"); $last_array=array_merge($array1,$array2); echo "<pre>"; print_r($last_array); echo "</pre>"; --------------------------------------- Result: --------------------------------------- Array ( [0] => [test] => 1 [testing] => 2 ) --------------------------------------- Please note that not only does array_merge allow the "false" to be passed in, but when it is, a mysterious [0] appears in the results (null array value?) Reproduce code: --------------- <?php $array1=false; $array2=array("test"=>"1","testing"=>"2"); $last_array=array_merge($array1,$array2); echo "<pre>"; print_r($last_array); echo "</pre>"; ?> Expected result: ---------------- Either an "invalid argument" for the "false" being passed in, or no extra Null array value appended to the resulting array. Actual result: -------------- Array ( [0] => [test] => 1 [testing] => 2 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25494&edit=1