HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
PHP String Reference : Replace the characters "ia" in the string with "eo"
The strtr() function translates certain characters in a string.
or
Parameter | Description |
---|---|
string | Required. Specifies the string to translate |
from | Required (unless array is used). Specifies what characters to change |
to | Required (unless array is used). Specifies what characters to change into |
array | Required (unless to and from is used). An array containing what to change from as key, and what to change to as value |
Return Value: | Returns the translated string. If the array parameter contains a key which is an empty string (""), it will return FALSE. |
---|---|
PHP Version: | 4+ |
Replace the string "Hello world" with "Hi earth":
<?php
$arr = array("Hello" => "Hi", "world" => "earth");
echo strtr("Hello world",$arr);
?>
❮ PHP String Reference