note 22157 deleted from function.array-merge by sniper

From: Date: Mon, 06 Oct 2003 22:55:03 +0000
Subject: note 22157 deleted from function.array-merge by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57919@lists.php.net to get a copy of this message
Note Submitter: carlos AT wfmh DOT org DOT pl ---- If you merges two (or more arrays, i.e. $a1, $a2) with keys that exists in both arrays and you want in result the array with only new (non existing in $a1) keys integrated and rest of $a1 untouched, put the array you want to save as the latter argument. I.e. to asimilate $a2 by $a1: $a1 = array("a"=>10, "b"=>20); $a2 = array("a"=>0, "c"=>30); do: array_merge( $a2, $a1 )); otherwise value with key "a" will be replaced with that one from $a2 and we don't want this. If you have more arrays, the order of array_merge() argumens in case of such merge should (in general) be descending from less to most 'importatant'.

« previous php.notes (#57919) next »