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