我只想删除 anchor 标记和实际网址。
例如,<a href="http://www.example.com">test www.example.com</a>
会变成test
.
谢谢。
最佳答案
我经常使用:
$string = preg_replace("/<a[^>]+>/i", "", $string);
记住 strip_tags
可以从字符串中删除所有标签,“白名单”中指定的标签除外。这不是您想要的,但为了详尽无遗,我也告诉您这一点。
编辑:我找到了获得该正则表达式的原始来源。为了公平起见,我想引用作者:http://bavotasan.com/tutorials/using-php-to-remove-an-html-tag-from-a-string/
关于php - 使用 PHP 删除 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5844442/