note 73616 added to function.preg-match
| From: | trevorhughdavis at gmail dot com | Date: | Sat, 03 Mar 2007 23:19:14 +0000 |
| Subject: | note 73616 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124052@lists.php.net to get a copy of this message | ||
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];
}
}
----
Server IP: 194.145.210.4
Probable Submitter: 216.15.32.14
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- https://master.php.net/note/edit/73616
Del: integrated -- https://master.php.net/note/delete/73616/integrated
Del: useless -- https://master.php.net/note/delete/73616/useless
Del: bad code -- https://master.php.net/note/delete/73616/bad+code
Del: spam -- https://master.php.net/note/delete/73616/spam
Del: non-english -- https://master.php.net/note/delete/73616/non-english
Del: in docs -- https://master.php.net/note/delete/73616/in+docs
Del: other reasons-- https://master.php.net/note/delete/73616
Reject -- https://master.php.net/note/reject/73616
Search -- https://master.php.net/manage/user-notes.php