例如:
替换为
求处理办法。
使用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>
"
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
3 回答2.3k 阅读✓ 已解决
3 回答2.1k 阅读✓ 已解决
preg_replace
正则表达式的搜索和替换