Old 14-08-2006, 13:19   #1 (permalink)
Skidzy McFergus
Registered User
 
Join Date: Nov 2005
Posts: 57
unusual URLs

Hi, is there a PHP function, class or something that will return the domain name/home page of a given URL? i.e. how could i find out what site "http:/terra.di.fct.unl.pt/docs/php/function.trim.php.htm"
...belongs to. I have used parse_url which works for most urls but not for ones like the above.
  Reply With Quote
Old 14-08-2006, 14:00   #2 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,238
I don't see why parse_url wouldn't work. Are you sure it's not because you've only added one trailing slash after http: ?
  Reply With Quote
Old 14-08-2006, 16:26   #3 (permalink)
Skidzy McFergus
Registered User
 
Join Date: Nov 2005
Posts: 57
Ok, how about urls like "forums.gentoo.org", parse_url() doesn't return "gentoo.org" it returns "forums.gentoo.org".

Last edited by Skidzy McFergus : 14-08-2006 at 16:55.
  Reply With Quote
Old 15-08-2006, 04:44   #4 (permalink)
mx
fucksocks™
 
mx's Avatar
 
Join Date: Jun 2005
Location: in the boosh
Posts: 1,615
Couldn't you split the string by the first fullstop i.e

PHP Code:
function getDomain($domain) {
$firststop stripos($domain);
$top_domain substr($domain$firststop)
return 
$top_domain;

__________________
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8