Menu Samaritan's Purse

ARRAY_MERGE

Merge one or more arrays

If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended.

SYNTAX

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

PARAMETERS

...

Variable list of arrays to merge.

RETURN

Returns the resulting array. 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] => 2
    [b] => 3
)

INTERNAL

array_combine

array_values

array_walk

EXTERNAL

PHP