Fixed and simplified array_replace description#1470
Fixed and simplified array_replace description#1470cartok wants to merge 1 commit intophp:masterfrom
Conversation
| <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. |
There was a problem hiding this comment.
Wouldn't that be the description of array_merge()? It is certainly not what array_replace() is doing; see e.g. https://3v4l.org/XfXpa.
It seems to me that the current description is a bit verbose, but basically correct; it is only misleading, that the description suggests that the first array would be mutated. Maybe similar wording as for str_replace() might be used.
There was a problem hiding this comment.
Yea ok, "joining" is propably not the best fitting word here.
What about this?
creates a new array by joining all given arrays in given order, replacing values of already existing keys.
In the end the arrays are joined but it goes by keys, not indices. They not are just concatenated like in array_merge
| <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. |
There was a problem hiding this comment.
| <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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Almost everything. If you describe something, it doesn't make much sense to start telling what it is not (let alone that a sentence should end with a period, and there rarely is the need to have single sentence paragraphs). Furthermore, "joining" might easily mislead readers to associate that with https://www.php.net/join (yeah, that function is still a thing). |
If you think so. I rather want to read short facts and not complicated stories on such a simple thing. Feel free to close it. |
Based on discussion at PR php#1470
Based on discussion at PR #1470

Relates to: php/doc-de#76