You are allways whining about not being able to change the strange
parameters from functions due to backwards incompatibility. There a simple alias function would do the trick, and make things better and for new programers much more logical.
But now you do something like this, that makes absolutetly no sense to me.
And your doku at the given site is wrong, because I could live with a warning, but I cannot live with an empty array due to an array merge.
Instead of:
array_merge() was changed to accept only arrays. If a non-array variable is passed, a E_WARNING will be thrown for every such parameter. Be careful because your code may start emitting E_WARNING out of the blue.
It should say:
array_merge() was changed to accept only arrays. If a non-array variable is passed, a E_WARNING will be thrown for every such parameter and your resulting array will be empty. Be careful because your code may start emitting E_WARNING out of the blue and all of them will result in an empty array.
Can you at least explain me why it has been changed, before I go and change 150 lines of code, please?
Yours Sincerely
Sebastian
M. Sokolewicz wrote:
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
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php