array_mergeDescriptionThis function combines multiple values into a single array. Any number of values can be passed in the function call, including mixed arrays; any duplicate keys are overwritten by later elements in later arrays. Keys are merged in the order of the arrays that were passed. Subarrays are not recursed over and are not altered; if you want to merge arrays recursively, use array_merge_recursive() . Scalar values can also be passed; they're treated as single-element indexed arrays. Example$ax = array("a" => "alpha", "b" => "bravo", "c" => "charlie", "d" => "delta"); $ay = array("t" => "tango", "u" => "uniform", "v" => "victor", "w" => "whiskey", "x" => "x-ray"); $az = array("lima", "mike", "november"); echo "The merged arrays together form:\n"; print_r(array_merge($ax, $ay, $az)); Output: The merged arrays together form: Array ( [a] => alpha [b] => bravo [c] => charlie [d] => delta [t] => tango [u] => uniform [v] => victor [w] => whiskey [x] => x-ray [0] => lima [1] => mike [2] => november )
PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing
(Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch).
This material may be distributed only subject to the terms and conditions set forth
in the Open Publication License, v1.0 or later (the latest version is presently available at
http://www.opencontent.org/openpub/).
The authors of this book have elected not to choose any options under the OPL. This online book was obtained
from http://www.fooassociates.com/phpfer/
and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4
for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All
persons and entities shall have neither liability nor responsibility to any person or entity with respect to
any loss or damage arising from the information contained in this book.
|