...

View Full Version : debug check email ending



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



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

switch($type)
{
case "com";
case "net";
case "us";
case "info";
case "org";
case "biz";
$domainvalid=true; break;
default;$filtered=1;
}


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?

lavinpj1
06-21-2006, 12:31 PM
<?php
$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.

~Phil~

esthera
06-21-2006, 12:56 PM
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