Introduction to strtr functions in PHP (str_replace ). Strtr has two forms: stringstrtr (string $ str, string $ from, string $ to) stringstrtr (string $ str, array $ replace_pairs) when the first type is used, the strtr parameter $ from, $ to has two forms:
String strtr (string $ str, string $ from, string $)
String strtr (string $ str, array $ replace_pairs)
When the first type is used, the string length of the parameter $ from and $ to must be the same; otherwise, the extra characters (whether $ from or $ to) are ignored.
For example, $ str = 'A-= B ';
When $ from = '-=', $ to = 'CD', output 'acdb' because '-=' is of the same length as 'CD', no problem.
When $ from = '-=', $ to = 'Cde', the output 'acdb' is ignored.
When $ from = '-=', $ to = 'C', output 'AC = B ',' = 'in $ from is ignored.
In the second form, there is no such problem, and redundant notes will not be ignored.
Therefore, if the strtr function is intentionally used to replace str_replace and the first form is used, pay attention to this feature, which may be a trap.
The http://www.bkjia.com/PHPjc/324334.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324334.htmlTechArticlestrtr has two forms: string strtr (string $ str, string $ from, string $ to) string strtr (string $ str, array $ replace_pairs) when the first type is used, the parameter $ from, $...