note 93839 added to function.array-merge

From: Date: Fri, 02 Oct 2009 15:36:04 +0000
Subject: note 93839 added to function.array-merge
Groups: php.notes 
Request: Send a blank email to php-notes+get-161221@lists.php.net to get a copy of this message
More on the union (+) operator: the order of arrays is important and does not agree in my test below with the other posts. The 'unique' operation preserves the initial key-value and discards later duplicates. PHP 5.2.6-2ubuntu4.2 $a1=array('12345'=>'a', '23456'=>'b', '34567'=>'c', '45678'=>'d'); $a2=array('34567'=>'X'); $a3=$a1 + $a2; $a4=$a2 + $a1; print('a1:'); print_r($a1); print('a2:'); print_r($a2); print('a3:'); print_r($a3); print('a4:'); print_r($a4); a1:Array ( [12345] => a [23456] => b [34567] => c [45678] => d ) a2:Array ( [34567] => X ) a3:Array ( [12345] => a [23456] => b [34567] => c [45678] => d ) a4:Array ( [34567] => X [12345] => a [23456] => b [45678] => d ) ---- Server IP: 64.71.164.2 Probable Submitter: 92.27.4.182 ---- Manual Page -- http://www.php.net/manual/en/function.array-merge.php Edit -- https://master.php.net/note/edit/93839 Del: integrated -- https://master.php.net/note/delete/93839/integrated Del: useless -- https://master.php.net/note/delete/93839/useless Del: bad code -- https://master.php.net/note/delete/93839/bad+code Del: spam -- https://master.php.net/note/delete/93839/spam Del: non-english -- https://master.php.net/note/delete/93839/non-english Del: in docs -- https://master.php.net/note/delete/93839/in+docs Del: other reasons-- https://master.php.net/note/delete/93839 Reject -- https://master.php.net/note/reject/93839 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161221) next »