merge two or more arrays into one array in PHP

merge two or more arrays into one array in PHP

In this post we will give you information about merge two or more arrays into one array in PHP. Hear we will give you detail about merge two or more arrays into one array in PHPAnd how to use it also give you demo for it if it is necessary.

Use the PHP array_merge() function


You can use the PHP array_merge() function to merge the elements or values of two or more arrays together into a single array. The merging is occurring in such a way that the values of one array are appended to the end of the previous array. Let’s check out an example:



<?php
$array1 = array(1, "fruit" => "banana", 2, "monkey", 3);
$array2 = array("a", "b", "fruit" => "apple", "city" => "paris", 4, "c");
 
// Merging arrays together
$result = array_merge($array1, $array2);
print_r($result);
?>


 

Hope this and post will helped you for implement merge two or more arrays into one array in PHP. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  2  =  10

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US