note 96844 deleted from function.array-merge by cmb

From: Date: Mon, 19 Nov 2018 17:03:29 +0000
Subject: note 96844 deleted from function.array-merge by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-209729@lists.php.net to get a copy of this message
Note Submitter: nekroshorume at gmail dot com ---- be aware there is a slight difference: <?php $array1 = array('lang'=>'js','method'=>'GET'); $array2 = array('lang'=>'php','browser'=>'opera','method'=>'POST'); ?> BETWEEN: <?php array_merge($array2,$array1); ?> outputs: Array ( [lang] => js [browser] => opera [method] => GET ) notice that the repeated keys will be overwritten by the ones of $array1, maintaining those, because it is the array that is being merged AND <?php array_merge($array1,$array2); ?> outputs: Array ( [lang] => php [method] => POST [browser] => opera ) here the oposite takes place: array1 will have its elements replaced by those of array2.

« previous php.notes (#209729) next »