Lior Lior - 1 year ago 77
PHP Question

Remove urls using PHP

I'd like to only remove the anchor tags and the actual urls.

For instance,

<a href="">test</a>
would become


Answer Source

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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download