Re: array_merge changed behaviour in Php5??
| From: | M. Sokolewicz | Date: | Sun, 05 Sep 2004 10:27:01 +0000 |
| Subject: | Re: array_merge changed behaviour in Php5?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195903@lists.php.net to get a copy of this message | ||
You can find more info about this here:
http://www.php.net/manual/en/migration5.incompatible.php
I2eptilex wrote:
Hi, I came across a strange behaviour in array_merge since I installed php5. I merge three arrays, one of them can be empty. So not an array at all. In php 4.3.6 that I had before, there was no warning and the two first arrays were merged. In php5 on the other hand, there is a warning and my array is empty. Is this behaviour wanted? Or is this just me having this problem? I find it pretty ugly, either there is more than a warning, or at least the first two arrays should be merged and given back. $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);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 /Library/WebServer/Documents/regis24/admin/test_array_merge.php on line 7 I would define this behaviour as backwards incompatible. How about you? Sebastian