View Full Version : debug check email ending

06-21-2006, 10:35 AM
I have the following code:

list($temail, $hostname) = explode("@", $temail); list($name, $type) = explode(".",$hostname);

case "com";
case "net";
case "us";
case "info";
case "org";
case "biz";
$domainvalid=true; break;

what it does is check the email and if the domain is not one on the list then it sets $filtered=1.
the problem with this is that it is also filetering something like a@a.a.com (wherever there is a subdomain.) how can I fix this?

06-21-2006, 11:31 AM
$address = "jim@a.a.com";

preg_match_all('@(\.[a-z]*)@', $address, $matches);

$tld = $matches[0][count($matches[0]) - 1];

echo $tld; //returns .com

You can use your case stuff on $tld.


06-21-2006, 11:56 AM
thanks so how would I combine this with teh above to filter all those not in the case.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum