Try this function:
function getDomainParts($email) {
$posDom = strrpos($email, "@");
$posTLD = strrpos($email, ".");
return array(
"tld" => substr($email, $posTLD+1),
"domain" => substr($email, $posDom+1, $posTLD-$posDom-1)
);
}
$tests = array(
"test1@college.edu",
"test2@bobstruckingacademy.edu",
"test3@test.com"
);
foreach($tests as $k => $v) {
$temp = getDomainParts($v);
if($temp['tld'] == "edu")
echo("College: " . $temp['domain'] . "<br>");
else
echo("Not Edu Address: " . $v . " (" . $temp['tld'] . ")<br>");
}
Output:
College: college
College: bobstruckingacademy
Not Edu Address: test3@test.com (com)
I understand that this probably won't get you exactly what you are asking. If I put in MSU (as an example) does that mean Misouri State? Mississippi State? Michigan State? Without a lookup array or table of some kind, 'msu' is as good as your registration form can get.
Alternatively, you could provide a drop down that contains all colleges and have the user select one, but then again you're still resorting to typing out all of the college names.
Edit
This link may help you: List of edu Domains