MongooseA living laboratory of myriad worlds.

All help topics · Link to this topic

Showing help on 'strtr()'

Syntax: strtr (STR source, STR str1, STR str2 [, case-matters])

Transforms the string source by replacing the characters specified by str1 with the corresponding characters specified by str2. All other characters are not transformed. If str2 has fewer characters than str1 the unmatched characters are simply removed from source. By default the transformation is done on both upper and lower case characters no matter the case. If case-matters is provided and true, then case is treated as significant.

strtr("foobar", "o", "i") => "fiibar"
strtr("foobar", "ob", "bo") => "fbboar"
strtr("foobar", "", "") => "foobar"
strtr("foobar", "foba", "") => "r"
strtr("5xX", "135x", "0aBB", 0) => "BbB"
strtr("5xX", "135x", "0aBB", 1) => "BBX"
strtr("xXxX", "xXxX", "1234", 0) => "4444"
strtr("xXxX", "xXxX", "1234", 1) => "3434"