If I have a variable that contains a URL, then how can I get the base URL? That is,
$url = 'http://www.domain.com/some/stuff/that/I/do/not/want/';
$base_url = some_clever_function($url);
// $base_url is now set equal to 'domain.com'
How can I do this?