[thelist] Finding domain name w/ php

CDitty mail at redhotsweeps.com
Sat Jun 9 17:16:28 CDT 2001


I am trying to find the prefix & suffix of a url of a site via php.  I have 
been pretty successful so far, but I have run into a small roadblock. I can 
find these easily enough for urls like http://www.redhotsweeps.com & 
http://redhotsweeps.com.  But I can't seem to get it when the url is like 
http://games.redhotsweeps.com.

Can someone look over my code and see if you can see the solution?

$r_url = explode(".", strtolower($HTTP_REFERER)); // Breaks the referering 
url up at the . points to give the site name
if($r_url[0] != "http://www"){
         $r_url[2] = $r_url[1];
         $r_url[1] = substr($r_url[0], 7);
}
$suffix_url = explode("/", $r_url[2]); // Break the $r_url[2} variable up 
at the / to give the site suffix. (.com, .net, etc)
$site_url = strtolower("$r_url[1].$suffix_url[0]"); // combines the whole 
thing into 1 string for comparison and lowercases it.

Any help is appreciated.

Thanks

Chris

<tip>
When chopping images for display, be carefull not to break the <img> tag on 
multiple lines.  Some browsers will
put a white line through the image.
</tip>





More information about the thelist mailing list