Menu Riverview Church

ARRAY_MERGE_RECURSIVE

Merge one or more arrays recursively

If the input arrays have the same string keys, then the values for these keys are merged together into an array, and this is done recursively, so that if one of the values is an array itself, the function will merge it with a corresponding entry in another array too. If, however, the arrays have the same numeric key, the later value will not overwrite the original value, but will be appended.

SYNTAX

array_merge_recursive ([ array $... ] ) : array

PARAMETERS

...

Variable list of arrays to recursively merge.

RETURN

An array of values resulted from merging the arguments together. If called without any arguments, returns an empty array.

EXAMPLES

VOID

Array
(
)

ARRAY | INDEXED

Array
(
    [0] => 0
    [1] => 1
)

ARRAY | ASSOCIATIVE

Array
(
    [a] => 0
    [b] => 1
)

... | INDEXED

Array
(
    [0] => 0
    [1] => 1
    [2] => 2
    [3] => 3
)

... | ASSOCIATIVE

Array
(
    [a] => 0
    [b] => 1
    [c] => 2
    [d] => 3
)

SAME KEY | INDEXED

Array
(
    [0] => 0
    [1] => 1
    [2] => 2
    [3] => 3
)

SAME KEY | ASSOCIATIVE

Array
(
    [a] => Array
        (
            [0] => 0
            [1] => 2
        )

    [b] => Array
        (
            [0] => 1
            [1] => 3
        )

)

PHP