strtr : 转换某些字符串
string strtr ( string str, string from, string to)
把字符串中的from替换成to 然后返回字符串。
无意中发现strtr函数能把字符串中的字符按照数组中的'key'=>'value'进行替换。
例子:
<?php
    $trans
= array("hello" => "hi", "hi" => "hello");
    echo
strtr("hi all, I said hello", $trans);
?>

结果:
hello all, I said hi
posted on 2009-06-05 22:03  睿达团队  阅读(171)  评论(0编辑  收藏  举报