note 48902 added to function.array-merge

From: Date: Tue, 11 Jan 2005 14:38:18 +0000
Subject: note 48902 added to function.array-merge
Groups: php.notes 
Request: Send a blank email to php-notes+get-83083@lists.php.net to get a copy of this message
Someone posted a function with the note: "if u need to overlay a array that holds defaultvalues with another that keeps the relevant data" <? //about twice as fast but the result is the same. //note: the sorting will be messed up! function array_overlay($skel, $arr) { return $arr+$skel; } //example: $a = array("zero","one","two"); $a = array_overlay($a,array(1=>"alpha",2=>NULL)); var_dump($a); /* NULL is ignored so the output is: array(3) { [1]=> string(5) "alpha" [0]=> string(4) "zero" [2]=> string(3) "two" } */ ?> ---- Manual Page -- http://www.php.net/manual/en/function.array-merge.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48902 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48902&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48902&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48902&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48902&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48902&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48902&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48902&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83083) next »