javascript - Use PHP to process the code produced by the rich text editor, replace the href of the a link with title="fish link" to bbb.com
習慣沉默
習慣沉默 2017-05-24 11:30:47
0
2
597

For example:

is replaced with

Seeking solutions.

習慣沉默
習慣沉默

reply all(2)
曾经蜡笔没有小新

preg_replace Regular expression search and replace

漂亮男人

Using preg_replace, I wrote a simple example:


$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>
"
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!