Skip to main content

Posts

Showing posts with the label str-replace

When to use strtr vs str_replace?

I'm having a hard time understanding when strtr would be preferable to str_replace or vice versa. It seems that it's possible to achieve the exact same results using either function, although the order in which substrings are replaced is reversed. For example: