PHP strtr() Function

P
PHP strtoupper() Function
PHP substr() Function

what is the syntax of the STRTR() function in php?

strtr(string,from,to)
ParameterDescription
stringRequired. Specifies the string to translate
fromRequired (unless array is used). Specifies what characters to change
toRequired (unless array is used). Specifies what characters to change into
arrayRequired (unless to and from is used). An array containing what to change from as key, and what to change to as value
PHP STRTR() method

examples of the STRTR() function

Example 1. In this example, we replace the characters “ia” in the string with “eo”.

<?php
echo strtr("Hilla Warld","ia","eo");
?>

Example 1. In this example, we replace the string “Hello world” with “Hi earth”.

<?php
$arr = array("Hello" => "Hi", "world" => "earth");
echo strtr("Hello world",$arr);
?>
PHP strtoupper() Function
PHP substr() Function

Add comment

Tutor Network

Share this

Learn PHP from A to Z