Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

array_replace_recursive

Description

The array_replace_recursive of Array for PHP replaces elements from passed arrays into the first array recursively.

Syntax

array_replace_recursive ( array $array1 [, array $... ] ) : array

Parameters

array1

The array in which elements are replaced.

...

Optional. Arrays from which elements will be extracted.

Return

Returns an array, or NULL if an error occurs.

Examples

1 · array1

<?

$array1 = array(0, 1, array(0, 1));

$return = array_replace_recursive($array1);

print_r($return);

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

)

2 · ...

<?

$array1 = array(0, 1, array(0, 1));
$array2 = array("replace", 2 => array("replace"));

$return = array_replace_recursive($array1, $array2);

print_r($return);

?>
Array
(
    [0] => replace
    [1] => 1
    [2] => Array
        (
            [0] => replace
            [1] => 1
        )

)
HomeMenu