PHP's STRTR function, the performance is higher than the Str_replace function, can replace the str_replace to use. 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.
http://www.bkjia.com/PHPjc/632263.html www.bkjia.com true http://www.bkjia.com/PHPjc/632263.html techarticle PHP's STRTR function, performance is higher than the Str_replace function, can be used instead of str_replace. STRTR in two forms: String Strtr (String $str, string $from, str ing $to) string St ...