strtr.xml Fix the confusing example, CS - #5754
Merged
Merged
Conversation
The first example — with multi-byte characters — seems confusing. The function replaces only the first byte of a multi-byte character `å`, and the output shows a black diamond with a question mark (U+FFFD). Instead of a real example, the page actually offers pseudocode, which an unprepared reader has to slog through to finally understand the substitution algorithm: ä → a, å → a, ö → o. I don't know why 🤷♂️
kamil-tekiela
requested changes
Aug 10, 2026
Comment on lines
+161
to
+164
| echo strtr("baab", "ab", "01"), "\n"; | ||
| $replace_pairs = ["ab" => "01"]; | ||
| echo strtr("baab", $replace_pairs); |
Member
There was a problem hiding this comment.
Since you removed the broken example from the first one, maybe it would be a good idea to add it here, so that readers see why it doesn't work with multibyte strings and 3-parameter mode. See https://www.php.net/manual/en/function.strtr.php#111270
Member
Author
There was a problem hiding this comment.
Please take a look now. Is the example of replacement in a multi‑byte string clear?
kamil-tekiela
requested changes
Aug 10, 2026
Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
kamil-tekiela
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first example — with multi-byte characters — seems confusing. The function replaces only the first byte of a multi-byte character
å, and the output shows a black diamond with a question mark (U+FFFD).Instead of a real example, the page actually offers pseudocode, which an unprepared reader has to slog through to finally understand the substitution algorithm: ä → a, å → a, ö → o. I don't know why 🤷♂️