note 122652 deleted from function.array-merge by salathe
| From: | salathe@php.net | Date: | Mon, 06 Sep 2021 22:45:48 +0000 |
| Subject: | note 122652 deleted from function.array-merge by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216898@lists.php.net to get a copy of this message | ||
Note Submitter: withtvpeter at gmail dot com
----
Suffice to add, array_merge() creates a new array from the supplied array(s) and does not modify the
supplied array(s). Example:
$array1 = ["a" => "one", "b"=>"two"];
$array2 = [ "c" => "three", "d" => "four"];
$mergedArray = array_merge($array1, $array2);
print_r($mergedArray); // => ["a"=> "one", "b"=>
"two", "c"=>"three", "d"=>"four"];
print_r($array1); //=> ["a"=>"one", "b"=>"two"];