我有一个变量,像这样的值:PHP的preg_match找到相关词语
$sentence = "When it comes time to renew your auto insurance policy, be aware of how your carrier handles renewals";
而且我有以下值数组变量:
$searches = array('aware', 'aware of', 'be aware', 'be aware of');
$replaces = array('conscious', 'conscious of', 'remember', 'concentrate on');
我想找个只是“知道的',然后替换为'专注于'。输出象下面这样:
当谈到时间更新您的汽车保险政策,专注于运营商如何处理更新
只有
搜索“知道”作为相关同义词替换而不是别人。谢谢你的帮助。
好吧,这里的新代码:
$searches = array('aware of', 'be aware of', 'be aware', 'aware');
$replaces = array('conscious of', 'concentrate on', 'remember', 'conscious');
这是一个动态数组($searches
),希望大家理解......我们知道,以获得最佳代名词更换使用“”注意'取代'专心'。输出象下面这样:
当谈到时间更新您的汽车保险政策,专注于运营商如何处理更新
排序字符串长度的搜索模式。并且可能在它们周围使用'\ b'锚。 – mario 2012-01-27 09:27:11
请在PHP中显示代码? – 2012-01-27 09:41:04