Here are some examples using explode() and parse_url()
First, explode()
//creates a two item array, the header (http, https,etc.)
$start_array=explode("//",$url);
//now get the first item off the array and use it as the starting point. If there isn't a
//second array item, don't do this. Just use http: as your starter...
if ($start_array[1]=="")
{
$starter="http:";
}
else
{
$starter=array_shift($start_array);
}
// now that we have stripped off the first starting part, we want to get the url base
$base=explode("/",$start_array);
//popping off first item of the array...
$item=array_shift($start_array);
//Just in case the "?" immediately follows the url...
$test=explode("?";$item);
$item=array_shift($test);
//checking for prefaced login info to the site...
$test=explode(":",$item);
if ($test[1]<>"") $item=array_pop($test);
//now, we parse it back together
$returned_url=$starter."//".$item
Now let's look at parse_url():
//split the url into it's elements
$start_array=parse_url($url);
//now parse the pieces back together
$return_url=$start_array[scheme]."://".$start_array[host];
All in all, laser's solution is much better than mine. Wish I'd known that feature before...