English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String String Functions Manual
The strtr() function is used to convert specified characters.
strtr(string, from, to)
It is used to convert characters or replace substrings
It returns the converted string
Serial Number | Parameters and Description |
---|---|
1 | string Required. The string to be converted. |
2 | from Required. The source character corresponding to the target character to be converted in the string. |
3 | to Required (unless using an array). The target character corresponding to the character from to be converted in the string. |
4 | array Required (unless using from and to). An array where the key name is the original character and the value is the target character. |
Try the following example, replace the character "ia" in the string with "eo":
<?php //Replace the character "ia" in the string with "eo" echo strtr("Hilla Warld", "ia", "eo"); echo '<br>'; //Convert phonetic characters äåö to aao echo strtr("Paäåö", "äåö", "aao"); ?>Test and see‹/›
Output Result
Hello World Paaao