Menu
Samaritan's Purse

STRTR

Translate characters or replace substrings

SYNTAX

strtr ( string $str , string $from , string $to ) : string
strtr ( string $str , array $replace_pairs ) : string

PARAMETERS

str

The string being translated.

from

The string being translated to to.

to

The string replacing from.

replace_pairs

The replace_pairs parameter may be used instead of to and from, in which case it's an array in the form array('from' => 'to', ...).

RETURN

Returns the translated string. If replace_pairs contains a key which is an empty string (""), FALSE will be returned. If the str is not a scalar then it is not typecasted into a string, instead a warning is raised and NULL is returned.

EXAMPLES

STR FROM TO

123de ed321

STR REPLACE_PAIRS

123de ed321

PHP