Character in the conversion string. Definition and usage
The strtr () function converts special characters in a string.
Syntax
Strtr (string, from, to) or
Strtr (string, array) parameter description
String1 is required. Specifies the string to be converted.
From is required (unless an array is used ). Specifies the character to be changed.
To is required (unless an array is used ). Specifies the character to be changed.
Array is required (unless from and to are used ). An array where the key is the original character and the value is the target character.
Description
If the length of from and to is different, the format is the shortest length.
Example
Example 1
The code is as follows:
Echo strtr ("Hilla Warld", "ia", "eo ");
?>
Output:
Hello World Example 2
The code is as follows:
$ Arr = array ("Hello" => "Hi", "world" => "earth ");
Echo strtr ("Hello world", $ arr );
?>
Output:
Hi earth