Thread: PHP help
View Single Post
Old 06-01-2004, 11:35 AM   #3
jessicaq
whore
 
 
Join Date: Jun 2004
Location: SoCal
Posts: 364/0.22
Threads: 0
FEMALE
Re: PHP help

You'd almost be better off splitting it up into an array and then checking the length of the last element.
<?php
$Host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
print $Host;
print "<br>";
$ArHost = split("\.",$Host);
$iSizeArr = count($ArHost);
If (strlen(end($ArHost)) < 3) {
#HOST HAS A 2-CHAR TOP LEVEL - IE: COUNTRY CODE
echo "domain name is: " . $ArHost[$iSizeArr-3] . "." . $ArHost[$iSizeArr-2] . "." . $ArHost[$iSizeArr-1] . "\n";
} else {
#HOST IS TYPICAL 3-CHAR TOP LEVEL
echo "domain name is: " . $ArHost[$iSizeArr-2] . "." . $ArHost[$iSizeArr-1] . "\n";
}
?>

Hope this helps.
Jessica.
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Spurl | quote |