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

array_replace

Description

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

Syntax

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

Parameters

array1

The array in which elements are replaced.

...

Arrays from which elements will be extracted. Values from later arrays overwrite the previous values.

Return

Returns an array, or NULL if an error occurs.

Examples

1 · array1

<?

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

$return = array_replace($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($array1, $array2);

print_r($return);

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

)
HomeMenu