<p>Im looking for a method (or function) to strip out the domain.ext part of any URL thats fed into the function. The domain extension can be anything (.com, .co.uk, .nl, .whatever), and the URL thats fed into it can be anything from <a href="http://www.domain.com" rel="noreferrer">http://www.domain.com</a> to www.domain.com/path/script.php?=whatever</p>

<p>Whats the best way to go about doing this?</p>

You can use
parse_url()
to do this:
```
```
$url = 'http://www.example.com';
$domain = parse_url($url, PHP_URL_HOST);
$domain = str_replace('www.','',$domain);
```
```
In this example, $domain should contain example.com, irrespective of it having www or not. It also works for a domain such as .co.uk