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