array_merge_recursive

array array_merge_recursive(mixed value_1, mixed value_2, mixed ...) 
value_1 Base array or value
value_2 Next value or array to merge
... Further values or arrays to be merged

Recursively merges all passed values into one array.

Returns:

Array containing the results of merging all passed values; NULL on failure

Description:

This function is like array_merge() except that identically-keyed nested arrays are recursed through and merged with each other, just as though array_merge() had been called on them.

Version:

PHP 4 since 4.0.1

See also:

array_merge() 

Example:

Recursively merge arrays
 $ax = array("a" => "alpha", "b" => "bravo", "z" => array("c" => "charlie", "d" => "delta")); $ay = array("t" => "tango", "u" => ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.