There are two forms of STRTR:
String Strtr (String $str, String $from, String $to)
String Strtr (string $str, array $replace _pairs)
When the first type is used, the arguments $from, $to string lengths must be the same, otherwise the extra (either $from or $to) characters are ignored.
For example $str = ' a-=b ';
When $from= '-= ', $to = ' CD ', Output ' aCDb ' because '-= ' is the same length as ' CD ', no problem.
When $from= '-= ', $to = ' CDE ', Output ' aCDb ', $to ' E ' is ignored.
When $from= '-= ', $to = ' C ', Output ' ac=b ', $from ' = ' is ignored.
Instead of using the second form, there is no problem, and the extra note is not ignored.
Therefore, if you deliberately replace str_replace with the STRTR function and use the first form, you must pay attention to this feature, which may be a trap.
The above describes the Replacer PHP strtr function use introduced Str_replace, including the replacer aspects of the content, I hope that the PHP tutorial interested in a friend helpful.