note 48406 deleted from function.array-merge by derek

From: Date: Thu, 23 Dec 2004 08:49:28 +0000
Subject: note 48406 deleted from function.array-merge by derek
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-82197@lists.php.net to get a copy of this message
Note Submitter: ulderico at maber dot com dot br ---- OK! For those who are migrating from PHP 4 to PHP 5, there's a little thing to take care of... When you array_merge in PHP 4, the compiler does not complain whether all arguments are typed as Array. In PHP 5, the programmers wickedly enforced all arguments TO BE arrays... Thusly: array_merge($var, $var2) [as it is...] will not work, in PHP5... It'll complain that Argument 1 and 2 ARE NOT arrays. Well, one cannot always tell whether a second argument will be an Array. Even some times, however more rarely, the first WILL NOT BE an array. Indeed, the PHP 4 behaviour was much more comfortable. (Is it B&R?) BUT YOU DO CAN cheat on PHP 5 and CAST the arguments as Arrays. Thusly: array_merge((array) $var, (array) $var2) [as it is...] WILL work. It seems that the PHP engine developers had just put a little check on typing, but had not changed very much in the logic of the tool. This will work on both conditions mentioned above. Dérico

« previous php.notes (#82197) next »