diff --git a/reference/array/functions/array-replace.xml b/reference/array/functions/array-replace.xml
index 97fb5d8dbf5d..f75604be4814 100644
--- a/reference/array/functions/array-replace.xml
+++ b/reference/array/functions/array-replace.xml
@@ -13,18 +13,13 @@
arrayreplacements
- array_replace replaces the values of
- array with values having the same keys in each of the following
- arrays. If a key from the first array exists in the second array, its value
- will be replaced by the value from the second array. If the key exists in the
- second array, and not the first, it will be created in the first array.
- If a key only exists in the first array, it will be left as is.
- If several arrays are passed for replacement, they will be processed
- in order, the later arrays overwriting the previous values.
+ array_replace creates a new array and assigns items into
+ it for each key in each of the provided arrays. If a key appears in multiple
+ input arrays, the value from the right-most input array will be used.
- array_replace is not recursive : it will replace
- values in the first array by whatever type is in the second array.
+ array_replace does not process elements items recursively,
+ it replaces the entire value for each key when it does a replacement.
@@ -70,21 +65,59 @@ $replacements = array(0 => "pineapple", 4 => "cherry");
$replacements2 = array(0 => "grape");
$basket = array_replace($base, $replacements, $replacements2);
-print_r($basket);
+var_dump($basket);
?>
]]>
&example.outputs;
grape
- [1] => banana
- [2] => apple
- [3] => raspberry
- [4] => cherry
-)
+array(5) {
+ [0]=>
+ string(5) "grape"
+ [1]=>
+ string(6) "banana"
+ [2]=>
+ string(5) "apple"
+ [3]=>
+ string(9) "raspberry"
+ [4]=>
+ string(6) "cherry"
+}
+]]>
+
+
+
+ Example of how nested arrays are handled
+
+ [ 'orange', 'lemon' ], 'pome' => [ 'apple' ] ];
+$replacements = [ 'citrus' => [ 'grapefruit' ] ];
+$replacements2 = [ 'citrus' => [ 'kumquat', 'citron' ], 'pome' => [ 'loquat' ] ];
+
+$basket = array_replace($base, $replacements, $replacements2);
+var_dump($basket);
+?>
+]]>
+
+ &example.outputs;
+
+
+ array(2) {
+ [0]=>
+ string(7) "kumquat"
+ [1]=>
+ string(6) "citron"
+ }
+ ["pome"]=>
+ array(1) {
+ [0]=>
+ string(6) "loquat"
+ }
+}
]]>