Example 1 — Translate Characters
With three arguments, each character in $from becomes the matching character in $to.
<?php
$text = "Hi all";
echo strtr($text, "ai", "eo"), PHP_EOL; How It Works
- Map the characters.
abecomeseandibecomeso. - Go letter by letter. "Hi" turns into "Ho".
- Keep the rest. Spaces and unmapped letters like
lstay as they are. - Result. "all" turns into "ell", so you see
Ho ell.

