The strstr() is used to translate a character or replace substring.
Syntax
strstr(str, from, to) or strstr(str, arr)
Parameters
str − The string to translate
from − The characters to change. A required parameter if array is not used.
to − The characters to change into. A required parameter if array is not used.
arr − Array containing what to change from as key, and what to change to as value
Return
The strstr() function returns the translated string.
Example
The following is an example −
<?php $mystr = "kom lan" ; $str1 = "koml"; $str2 = "tomh"; echo strtr($mystr, $str1, $str2); ?>
Output
tom han