Tools, FAQ, Tutorials:
Merging Two Arrays into a Single Array in PHP
How To Merge Values of Two Arrays into a Single Array in PHP?
✍: FYIcenter.com
You can use the array_merge() function to merge two arrays into a single array. array_merge() appends all pairs of keys and values of the second array to the end of the first array. Here is a PHP script on how to use array_merge():
<?php
$lang = array("Perl", "PHP", "Java",);
$os = array("i"=>"Windows", "ii"=>"Unix", "iii"=>"Mac");
$mixed = array_merge($lang, $os);
print("Merged:\n");
print_r($mixed);
?>
This script will print:
Merged:
Array
(
[0] => Perl
[1] => PHP
[2] => Java
[i] => Windows
[ii] => Unix
[iii] => Mac
)
⇒ Using an Array as a Queue in PHP
⇐ Joining Keys and Values into an Array in PHP
2017-01-11, ∼2999🔥, 0💬
Popular Posts:
How to convert a JSON text string to an XML document with PHP language? Currently, there is no built...
How To Access a Specific Character in a String? Any character in a string can be accessed by a speci...
How to start Docker Daemon, "dockerd", on CentOS systems? If you have installed Docker on your CentO...
What Happens If One Row Has Missing Columns? What happens if one row has missing columns? Most brows...
How To Move Uploaded Files To Permanent Directory in PHP? PHP stores uploaded files in a temporary d...