str_replace、preg_replace、strtr比较
博客迁移:时空蚂蚁http://cui.zhbor.com/
str_replace函数比preg_replace函数快,但strtr函数的效率是str_replace函数的四倍。
<?php $trans = array("hello" => "hi"); echo strtr("hi all, I said hello", $trans);
<?php $trans = array("hello" => "hi","hi" => "hello"); echo strtr("hi all, I said hello", $trans);