Latest web development tutorials

PHP array_merge_recursive () function

PHP Array Reference Complete PHP Array Reference

Examples

The two arrays into one array:

<?php
$a1=array("a"=>"red","b"=>"green");
$a2=array("c"=>"blue","b"=>"yellow");
print_r(array_merge_recursive($a1,$a2));
?>

Running instance »

Definition and Usage

array_merge_recursive () function is used to one or more arrays into one array.

This function array_merge () between different functions in the process two or more of the array elements have the same situation of keys. array_merge_recursive () will not be covering the key name, but multiple values ​​with the same key name recursively composed of an array.

NOTE: If you only () function to input an array array_merge_recursive, results and array_merge () the same, the function returns a new array with integer keys, the keys 0 to start re-indexing.


grammar

array_merge_recursive( array1,array2,array3... )

参数 描述
array1 必需。规定数组。
array2 可选。规定数组。
array3 可选。规定数组。

technical details

return value: Returns an array of the merger.
PHP version: 4.0.1+


PHP Array Reference Complete PHP Array Reference