Skip to content

Change behavior of strtr(["" => "x"]) #4792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nikic
Copy link
Member

@nikic nikic commented Oct 7, 2019

Previously:

  • If only ["" => "x"] was present, the original string was returned
    without warning.
  • If both ["" => "x"] and at least one more element was present,
    false was returned without warning.

New behavior:

  • Ignore "" keys in the replacement array (and perform any remaining
    replacement).
  • Throw a warning indicating that an empty string replacement has
    been ignored.

For reference: str_replace() ignores "" replacements, but silently.

cc @theodorejb

Previously:
 * If only ["" => "x"] was present, the original string was returned
   without warning.
 * If both ["" => "x"] and at least one more element was present,
   false was returned without warning.

New behavior:
 * Ignore "" keys in the replacement array (and perform any remaining
   replacement).
 * Throw a warning indicating that an empty string replacement has
   been ignored.
@theodorejb
Copy link
Contributor

Yes, I think this behavior makes a lot more sense.

@theodorejb
Copy link
Contributor

@nikic Can this be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants