PHP Program to merge two or more arrays

bookmark

<?php
    //Define two arrays
    $fruits = array('Apple', 'Orange');
    $vegetables = array('Cabbage', 'Brinjal');

    //Merging the array
    $garden = array_merge($fruits, $vegetables);

    //Since garden is array, to show it we use for loop
    for($i=0; $i < count($garden); $i++ ) {
        echo $garden[i];
    }
?>

 

Output


Apple
Orange
Cabbage
Brinjal