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, 1767🔥, 0💬
Popular Posts:
Where to find tutorials on API Management Services at Azure Portal? Here is a list of tutorials to a...
FYIcenter JSON Validator and Formatter is an online tool that checks for syntax errors of JSON text ...
How To Break a File Path Name into Parts in PHP? If you have a file name, and want to get different ...
How to Build my "sleep" Docker image from the Alpine image? I want the container to sleep for 10 hou...
How To Set session.gc_divisor Properly in PHP? As you know that session.gc_divisor is the frequency ...