strtr
strtr
===
strtr
It translate or replace a certain characters
This function returns a copy of str, translating all occurrences of each character in from to the corresponding character in to and returning the result.
Syntax:
=====
string strtr ( string str, string from, string to)
If from and to are different lengths, the extra characters in the longer of the two are ignored.
string strtr ( string str, array replace_pairs)
strtr() can be called with only two arguments. If called with two arguments it behaves in a new way: from then has to be an array that contains
string -> string pairs that will be replaced in the source string.
strtr() will always look for the longest possible match first and will *NOT* try to replace stuff that it has already worked on.
Example 1:
=======
$addr = “land”;
echo $addr = strtr($addr, “l”, “s”);
The result in $addr is “sand”.
Example 2:
=======
$trans = array(”hello” => “hi”, “hi” => “hello”);
echo strtr(”hi all, I said hello”, $trans) . “\n”;
The result isĀ “hello all, I said hi”,
