note 45445 modified in migration5.incompatible by danbrown
| From: | danbrown@php.net | Date: | Sun, 03 Aug 2008 02:37:21 +0000 |
| Subject: | note 45445 modified in migration5.incompatible by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-143078@lists.php.net to get a copy of this message | ||
Be careful with array_merge in PHP5.1 not only a E_WARNING is thrown, but also the result is an
empty array. So if you merge two select queries and the last one is empty you will end up with no
array at all.
<?php
$array_1 =
array('key1'=>'oranges','key2'=>'apples');
$array_2 =
array('key3'=>'pears','key4'=>'tomatoes');
$array_3 = null;
$arr_gemerged = array_merge($array_1,$array_2,$array_3);
print_r($arr_gemerged);
echo "<br>";
?>
Result on php4:
Array ( [key1] => oranges [key2] => apples [key3] => pears [key4] => tomatoes )
Result on php5:
Warning: array_merge() [function.array-merge]: Argument #3 is not an array in
/removed/by/danbrown/for/manual.php on line 7
--was--
Be careful with array_merge in PHP5.1 not only a E_WARNING is thrown, but also the result is an
empty array. So if you merge two select queries and the last one is empty you will end up with no
array at all.
$array_1 = array('key1'=>'oranges','key2'=>'apples');
$array_2 =
array('key3'=>'pears','key4'=>'tomatoes');
$array_3 = null;
$arr_gemerged = array_merge($array_1,$array_2,$array_3);
echo "result:<br>";
print_r($arr_gemerged);
echo "<br>";
Result on php4:
result:
Array ( [key1] => oranges [key2] => apples [key3] => pears [key4] => tomatoes )
Result on php5:
Warning: array_merge() [function.array-merge]: Argument #3 is not an array in
/Library/WebServer/Documents/regis24/admin/test_array_merge.php on line 7
result:
http://php.net/manual/en/migration5.incompatible.php