note 44006 added to function.array-merge

From: Date: Mon, 12 Jul 2004 12:42:32 +0000
Subject: note 44006 added to function.array-merge
Groups: php.notes 
Request: Send a blank email to php-notes+get-73094@lists.php.net to get a copy of this message
As you know, guys, because of fixing bug #25494, starting from PHP 5.0.0 Beta2 the function doesn't accept scalar values as secondary arguments. It means if you try to run <? array_merge(array('array'),'scalar'); ?> the function throws a warning and returns <? NULL ?> instead of <? array(0=>'array',1=>'scalar');?>. If you want the old behavior of the merge function, use this instead: <? function array_merge_php4($array1,$array2){ $return=array(); foreach(func_get_args() as $arg){ if(!is_array($arg)){ $arg=array($arg); } foreach($arg as $key=>$val){ if(!is_int($key)){ $return[$key]=$val; }else{ $return[]=$val; } } } return $return; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.array-merge.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44006 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44006&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44006&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#73094) next »