Merge Multiple Arrays into Single Array in PHP

Here is an example for merging two arrays.And using the array_merge() function in php. array_merge() function is used to concatenate the array values into an single array.

Source code :

<?php
$sample_array1 = array("fruit"=> "apple");
$sample_array2 = array("orange");
$result = array_merge($sample_array1, $sample_array2);
print_r($result);
?>

Output :

Array
(
    [fruit] => orange
 )

Output :


                

Comments :