<?PHP $str="The best time is no time at that time"; $str2=strtr($str,'t','d'); echo $str2; //The besd dime is no dime ad dhad dime $str3=strtr($str,'ta','di'); echo $str3; //The besd dime is no dime id dhid dime ?>
The function can also only have 2 parameters, the 1st is the target string, the 2nd is an associated array, and the key or the associated array will be replaced with its relative value.
<?PHP $str="The best time is no time at that time"; $arr=array("is"=>"was", "no"=>"the first"); $str2=strtr($str,$arr); echo $str2; //The best time was the first time at that time ?>