Account
Categories

array_merge()


It joins two or more arrays together. It mixes all the values into one single array. You can access every value using its key. The values from the first array come first, after that the values from the second array, then the third, and so on.

Syntax:

$new_array = array_merge($array1, $array2);

Example:

$fruits1 = array("Apple", "Banana");
$fruits2 = array("Mango", "Orange");

$result = array_merge($fruits1, $fruits2);

print_r($result);

Output:

Array
(
    [0] => Apple
    [1] => Banana
    [2] => Mango
    [3] => Orange
)