note 45059 added to function.array-merge

From: Date: Tue, 24 Aug 2004 19:37:59 +0000
Subject: note 45059 added to function.array-merge
Groups: php.notes 
Request: Send a blank email to php-notes+get-75216@lists.php.net to get a copy of this message
It would seem that array_merge doesn't do anything when one array is empty (unset): <?php //$a is unset $b = array("1" => "x"); $a = array_merge($a, $b}); //$a is still unset. ?> to fix this omit $a if it is unset:- <?php if(!IsSet($a)) { $a = array_merge($b); } else { $a = array_merge($a, $b); } ?> I don't know if there's a better way. ---- Manual Page -- http://www.php.net/manual/en/function.array-merge.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45059 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45059&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45059&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75216) next »