PHP Programing language

adplus-dvertising
array_merge_recursive() Function in PHP
Previous Home Next
adplus-dvertising

array_merge_recursive()

The array_merge_recursive() function merges one ore more arrays into one array. The array_merge_recursive() function is differ from the array_merge() function is when two or more array elements have the same key. The array_merge_recursive() function makes the value as an array, instead of override the keys.

Syntax:
array_merge_recursive(array1,array2,array3...)

In above syntax, "array1" specifies an array, "array2" specifies an array and "array3,..." specifies an array

Example:

<?php
$array1=array("Apple","Orange");
$array2=array("Orange","Mango");
print_r(array_merge_recursive($array1,$array2));
?>

Output:

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

Previous Home Next