|
|
|
|
|
|
![]() |
#12 |
Heh Heh Heh! Lisa! Vampires are make believe, just like elves and gremlins and eskimos!
Join Date: Jan 2006
Posts: 72
|
Here's a function I use to get only the domain from a URL.. I think that's what you're after? Just pass it a url and it will return the domain.
Code:
function getdomain($url) { // patterns we need to match $pattern_hostname = '/^(http:\/\/)?([^\/]+)/i'; $pattern_domain = '/[^\.\/]+\.[^\.\/]+(\.[^\.\/]{2})?$/'; // extract hostname from URL string @preg_match($pattern_hostname, $url, $matches); $hostname = $matches[2]; // extract sld.tld(.cctld if exists) @preg_match($pattern_domain, $hostname, $matches); $domain = $matches[0]; return $domain; } Hope this helps.. QD Last edited by QuickDraw; 2006-10-18 at 02:55 AM.. |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | Rate This Thread |
|
|