note 73616 deleted from function.preg-match by colder

From: Date: Mon, 18 Jun 2007 18:13:45 +0000
Subject: note 73616 deleted from function.preg-match by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127576@lists.php.net to get a copy of this message
Note Submitter: trevorhughdavis at gmail dot com ---- Getting the domain name out of a URL, improved Foreign countries have more bits to their domains. ie http://lse.ac.uk ac.uk is not the hostname. function bigworldhostname($url){ preg_match('@^(?:http://)?([^/]+)@i',$url, $matches); $host = $matches[1]; preg_match('/[^.]+\.[^.]+$/', $host, $usHost); if (strlen($usHost[0])>5){ return $usHost[0]; } else { preg_match('/[^.]+\.[^.]+\.[^.]+$/', $host, $restofWorldHost); return $restofWorldHost[0]; } }

« previous php.notes (#127576) next »