【发布时间】:2013-06-25 07:57:42
【问题描述】:
我有一个文件 filter.txt,其中包含我想在字符串上突出显示的单词。
过滤器.txt: 测试1 测试2
我的解决方案不起作用:
<?php
$file = file_get_contents('/home/user/filter.txt', true);
$keyword=$file;
$str="This is a test1 and test2 and test3";
$keyword = implode('|',explode(' ',preg_quote($keyword)));
$str = preg_replace("/($keyword)/i","<b>$0</b>",$str);
echo $str;
?>
有人吗?
【问题讨论】:
标签: php string filter highlight words