function splitURL($url) {
// Strip the host
preg_match("/^.{1,10}:\/\/[^\/\?]{1,}(\/|$|\?){1}/", $url, $match);
$match[0]=preg_replace("/^.{0,}:\/\//","",$match[0]);
$match[0]=str_replace("?","",$match[0]);
$match[0]=str_replace("/","",$match[0]);
$url_parts[host]=$match[0];
unset($match);
// Get the path
@preg_match("/".str_replace(".", '\.', $url_parts[host])."\/{1}[^\?]{0,}\//", $url, $match);
$match[0]=str_replace($url_parts[host], "", $match[0]);
$url_parts[path]=trim($match[0]);
if ($url_parts[path]=="") {
$url_parts[path]="/";
}
// Get the "file"
preg_match("/[^\/]{1}\/[^\/\?]{1,}(\?|$)/", $url, $match);
$match[0]=str_replace("/", "", $match[0]);
$match[0]=str_replace("?", "", $match[0]);
$match[0]=substr($match[0], 1);
$file=$match[0];
// Get the query
preg_match("/\?.{0,}/", $url, $match);
$query=$match[0];
// Get the DOMAIN
$parts=@explode(".", $url_parts[host]);
if (count($parts)<=2) {
$domain=$url_parts[host];
}
else {
$pos=strpos($url_parts[host], ".");
$domain=substr($url_parts[host], $pos+1);
}
// Get the protocol
preg_match("/^.{0,10}\/\//", $url, $match);
$protocol=$match[0];
// Build array
$r["host"]=$url_parts[host];
$r["path"]=$url_parts[path];
$r["file"]=$file;
$r["query"]=$query;
$r["domain"]=$domain;
$r["protocol"]=$protocol;
// .. and return it
return $r;
}