漂亮男人2017-05-24 11:32:47
使用preg_replace
, 写了个简单的例子:
$b = '
<a href="http://tool.chinaz.com/" title="fish link">df</a>
<a href="http://tool.chinaz.com/" title="no match">df</a>
<a href="http://tool.chinaz.com/" title="fish link">df</a>
';
var_dump(preg_replace('/<a.*title="fish link">/', '<a href="http://bbb.com" title="fish link">', $b));
output:
string(157) "
<a href="http://bbb.com" title="fish link">df</a>
<a href="http://tool.chinaz.com/" title="no match">df</a>
<a href="http://bbb.com" title="fish link">df</a>
"