Re: Getting domain out of a URL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> [snip]
> I receive posts from an open moderated forum that need to be filtered
> for urls. I've successfully managed to trap any entires that use 
> 'http://' 'www.' with the standard '.com' '.org', '.net' endings.
>
> What I need to do is to strip the prefix part ('http:// or http://www.
> or 'www') and suffix as well (the .com, etc.) I need only the domain 
> name.
> I can't seem to trim away the suffix part.
> [/snip]

What I've done in situations like this is reverse the text and tackle it 
from the _back_ end.  It's a simpler approach to first trim off the TLD, 
and then to extract only the (reversed) domain name.  (Tho', it's not a 
domain name without the TLD.)
Then, obviously, reverse your results.

HTH
Jonesy
-- 
  Marvin L Jones    | jonz          | W3DHJ  | linux
   38.24N  104.55W  |  @ config.com | Jonesy |  OS/2
    *** Killfiling google posts: <http://jonz.net/ng.htm>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux