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, ∼2837🔥, 0💬
Popular Posts:
What Is session_register() in PHP? session_register() is old function that registers global variable...
How to use urllib.parse.urlencode() function to encode HTTP POST data? My form data has special char...
How to add images to my EPUB books Images can be added into book content using the XHTML "img" eleme...
How to use the "return-response" Policy statement to build the response from scratch for an Azure AP...
What is the "__init__()" class method? The "__init__()" class method is a special method that will b...