正则表达式
eregi_replace("($keyword)","<font color=red>".\\1."</font>",$str);
preg_replace("'($keyword)'i","<font color=red>".\\1."</font>",$str);字符串处理
str_ireplace($keyword,"<font color=red>".$keyword."</font>",$str);

解决方案 »

  1.   

    更正一下 \\1 应该为"\\1"
    而 str_ireplace only be used in cvs
      

  2.   

    我试过用
    str_ireplace($keyword,"<font color=red>".$keyword."</font>",$str);这种方法会出现一个问题:比如像句子"hello,php!hi,PHP!",替代后变成了"hello,<font..>php</font>!hi,<font ..>php</font>!"
    也就是原来大写的PHP变成了小写使用正则表达式我还没试过,现在回去测试一下,先跟楼上的朋友说声谢谢
      

  3.   

    太好了,用正则表达式成功了,谢谢ccterran(iwind)