HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
PHP Array Reference : Merge two arrays into one array
The array_merge() function merges one or more arrays into one array.
Parameter | Description |
---|---|
array1 | Required. Specifies an array |
array2 | Optional. Specifies an array |
array3,... | Optional. Specifies an array |
Return Value: | Returns the merged array |
---|---|
PHP Version: | 4+ |
Changelog: | As of PHP 5.0, this function only accept parameters of type array |
Merge two associative arrays into one array:
<?php
$a1=array("a"=>"red","b"=>"green");
$a2=array("c"=>"blue","b"=>"yellow");
print_r(array_merge($a1,$a2));
?>
Using only one array parameter with integer keys:
<?php
$a=array(3=>"red",4=>"green");
print_r(array_merge($a));
?>
❮ PHP Array Reference