preg_replace("/\[(.+)\|(.+)\]/Us","<a href=\"\\1\">\\2</a>",$str);

解决方案 »

  1.   

    Description:
    string strtr ( string str, string from, string to)Notice:
    If from and to are different lengths, the extra characters in the longer of the two are ignored. 
    Pls replace strtr to str_replace
      

  2.   

    <?
    $text=$linktext;
    $text = str_replace("[", "<a href=\"", $text);
    $text = str_replace("|", "\">", $text);
    $text = str_replace("]", "</a>", $text);
    echo $text;
    ?>谢谢各位,这样解决了。