/* Pluck the protocol, hostname, and port number from a URL */ if (preg_match('{^(?P https? ):// (?P [^/:]+ ) (?: :(?P \d+ ) )? }x', $url, $UrlInfo)) { if (! $UrlInfo['port']) $UrlInfo['port'] = ($UrlInfo['proto'] == "http" ? 80 : 443); echo "Protocol: ", $UrlInfo['proto'], "\n"; echo "Host : ", $UrlInfo['host'], "\n"; echo "Port : ", $UrlInfo['port'], "\n"; } ----------------------------------------------------------------------------- Copyright 1997-2024 Jeffrey Friedl