例如:
替换为
求处理办法。
使用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>
"
13 回答12.8k 阅读
7 回答2k 阅读
3 回答1.1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
6 回答921 阅读✓ 已解决
2 回答1.3k 阅读✓ 已解决
2 回答1.4k 阅读✓ 已解决
preg_replace
正则表达式的搜索和替换