strtr

PHP 4, PHP 5, PHP 7, PHP 8
strtr - Translate characters or replace substrings

strtr( string$string, string$from, string$to ): string

Alternative signature (not supported with named arguments):

stringstrtr stringstring arrayreplace_pairs

Parameters

string

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', ...).

If replace_pairs contains a key which is an empty string (""), the element is ignored; as of PHP 8.0.0 E_WARNING is raised in this case.

Return Values

Returns the translated string.

Related Functions

Example of strtr

Show all examples for strtr

PHP Version:


Function strtr:

Strings Functions

Most used PHP functions