ID: 25494
Updated by: [EMAIL PROTECTED]
Reported By: enygma at phpdeveloper dot org
Status: Open
Bug Type: Arrays related
Operating System: Red Hat Linux
PHP Version: 4.3.2
New Comment:
1. Please use var_dump() instead of print_r()
2. The value in the merged array is (bool) false
Previous Comments:
[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 ""; print_r($last_array); echo "";
---
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:
---
"1","testing"=>"2");
$last_array=array_merge($array1,$array2);
echo ""; print_r($last_array); echo "";
?>
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