Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions reference/array/functions/array-replace.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@
<methodparam rep="repeat"><type>array</type><parameter>replacements</parameter></methodparam>
</methodsynopsis>
<para>
<function>array_replace</function> replaces the values of
<parameter>array</parameter> 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.
<function>array_replace</function> is not mutating
</para>
<para>
<function>array_replace</function> is not recursive : it will replace
values in the first array by whatever type is in the second array.
<function>array_replace</function> is not recursive
</para>
<para>
<function>array_replace</function> creates a new array by joining all given arrays in given order, replacing values of already existing keys.
Copy link
Contributor

@Crell Crell Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<function>array_replace</function> creates a new array by joining all given arrays in given order, replacing values of already existing keys.
<function>array_replace</function> creates a new array and assigns an item into it for each key in each of the provided arrays. If a key appears in multiple input arrays, the latter array's value is used.

How about this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me its implicit that the latter arrays value is used from the former short description. Another thing is that it does not only assigns keys to the new array

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little redundancy here is fine, especially as it's in a different section. Good point on the key/value question. I've updated the suggestion comment above.

</para>
</refsect1>
<refsect1 role="parameters">
Expand Down