php正则方法删除a标签的方法:使用函数【preg_replace】保留,代码为【$str = htmlspecialchars_decode($str);$str = preg_replace("/]*>(.*?)<\ a="">/is",】。
php正则方法删除a标签的方法:
目的:
使用正则表达式删除下列内容中的a标签,同时保留a标签内容
欢迎来到<a href="http://www.gaodaima.com">搞代码</a>www.yzlfxy.com
修改后:
欢迎来到<a href="http://www.gaodaima.com">搞代码</a>www.yzlfxy.com
解决方法:
$str = " 欢迎来到<a href="http://www.gaodaima.com">搞代码</a>www.yzlfxy.com "; $str = htmlspecialchars_decode($str); $<mark style="color:transparent">来源gaodaimacom搞#^代%!码网</mark>str = preg_replace("/]*>(.*?)<\/a>/is", "$1", $str); echo $str; 运行结果为: 1
想了解更多编程学习,敬请关注php培训栏目!
以上就是php如何正则方法删除a标签的详细内容,更多请关注搞代码gaodaima其它相关文章!