php正则方法删除a标签的方法:使用函数【preg_replace】保留,代码为【$str = htmlspecialchars_decode($str);$str = preg_replace("/]*>(.*?)<\ a="">/is",】。
php正则方法删除a标签的方法:
目的:
使用正则表达式删除下列内容中的a标签,同时保留a标签内容
欢迎来到www.yisu.com
修改后:
欢迎来到www.yisu.com
解决方法:
$str = "
欢迎来到www.yisu.com
";
$str = htmlspecialchars_decode($str);
$str = preg_replace("/]*>(.*?)<\/a>/is", "$1", $str);
echo $str;
运行结果为:
1
上一篇:php设置mime的方法