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, 1905🔥, 0💬
Popular Posts:
How to access URL template parameters from "context.Request.Matched Parameters"object in Azure API P...
How to install .NET Framework in Visual Studio Community 2017? I have the Visual Studio Installer in...
How to use the "send-one-way-request" Policy statement to call an extra web service for an Azure API...
How to search for the first match of a regular expression using re.search()? The re.search() functio...
Where to get a JSON.stringify() Example Code in JavaScript? Here is a good JSON.stringify() example ...