array_merge_recursive — Merge two arrays recursively.
array_merge_recursive(mixed $map_or_list, mixed $map_or_list_2) : array
map_or_list
- Initial (map or list) to merge.
map_or_list_2
- (Map or list) to merge into initial (map or list).
An array containing the result of two arrays merged recursively.
Example #1 array_merge_recursive()
$map:
(
test: (circle: 1, square: 2, triangle: 3),
test2: numbers,
test3: names
);
$map2:
(
test: (circle: blue, triangle: bob),
test2: colors,
test4: shapes
);
$result: array_merge_recursive($map, $map2);
Output:
(
test: (circle: blue, square: 2, triangle: bob),
test2: colors,
test3: names,
test4: shapes
);
Example #2 array_merge_recursive()
$list:
(
(1, 2, 3),
(4, 5, 6)
);
$list2:
(
(7, 8, 9),
(10, 11, 12)
);
$result: array_merge_recursive($list, $list2);
Output:
(
0: (
0: 1,
1: 2,
2: 3
),
1: (
0: 4,
1: 5,
2: 6
),
2: (
0: 7,
1: 8,
2: 9
),
3: (
0: 10,
1: 11,
2: 12
)
);