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);

 

posted @ 2014-03-22 13:25  hongbo819  阅读(212)  评论(0编辑  收藏  举报