...

View Full Version : asp to php



esthera
04-27-2006, 12:19 PM
can someone help me translate the following code from asp to php:

emailhost=Mid(email, InStr(Email, "@") + 1)
n=instrrev(emailhost,".")
domainend=right(emailhost,len(emailhost)-n)
domainend=lcase(domainend)

select case domainend
case "edu","com","net","us","info","org","biz,".cc"
domainvalid=true
case else
filtered=1
end select

MRMAN
04-27-2006, 12:30 PM
list($email, $hostname) = explode("@", $email);
list($name, $type) = explode(".",$hostname);

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



think that should be close

NancyJ
04-27-2006, 12:38 PM
ok, it seems to me that all you're trying to do is check that everything in the string after the last . is one of those in your list.
This is what I would do - throwing in checking for the @ too ;)


if(strpos(email, "@")!==false)
{
$emailParts = explode(".", $email);
$domain = strtolower($emailParts[count($emailParts)-1]);
$allowedDomains = array("edu","com","net","us","info","org","biz","cc");
if(in_array($domain, $allowedDomains))
{
$domainValid = true;
}
else
{
filtered = 1
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum