使用PHP删除网址 [英] Remove urls using PHP
本文介绍了使用PHP删除网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想删除锚标记和实际的网址.
例如,<a href="http://www.example.com">test www.example.com</a>
将变为test
.
I'd like to only remove the anchor tags and the actual urls.
For instance, <a href="http://www.example.com">test www.example.com</a>
would become test
.
谢谢.
推荐答案
为补充gd1的答案,这将获得所有URL:
To complement gd1's answer, this will get all the URLs:
// http(s)://
$txt = preg_replace('|https?://www\.[a-z\.0-9]+|i', '', $txt);
// only www.
$txt = preg_replace('|www\.[a-z\.0-9]+|i', '', $txt);
这篇关于使用PHP删除网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文