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, .what
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