PHP strtr() Function

PHP strtr() Function

The strtr() function in PHP translates or replaces certain characters in a string.

Syntax

or

Parameter

str(required)– This parameter specifies the string to translate

from(required)– This parameter represents the string being translated to the parameter ‘to’.

to(required)– It specifies what characters to change.

replace_pairs(optional)– This parameter signifies an array containing what to change from as key, and what to change to as value.

Return

This function returns the translated string. If the replace_pairs parameter contains a key which is an empty string (“”), it will return FALSE.

Example 1

Output

Example 2

Output

Example 3

Output

Example 4

Output