Let us say I've got a registration form with email validation for college edu emails only setup.

An amount be the easiest method to obtain the college title using PHP from that to place in to the database?

The only method I'm able to think about is by using if college.edu address, then title = college. But you will find 1000's of schools which does not appear efficient.

Go ahead and take string that contains the e-mail value and split it in the "@" after which in the ".". When the third object from the resulting array equals edu, adding the 2nd object from the array for your database.

Would that meet your needs or shall we be held misunderstanding your inquiry?

Do 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(

foreach($tests as $k => $v) {
    $temp = getDomainParts($v);
    if($temp['tld'] == "edu") 
        echo("College: " . $temp['domain'] . "<br>");
        echo("Not Edu Address: " . $v . " (" . $temp['tld'] . ")<br>");


College: college

College: bobstruckingacademy

Not Edu Address: test3@test.com (com)

I realize this most likely will not enable you to get exactly what you're asking. Basically place in MSU (for example) does which means that Misouri Condition? Mississippi Condition? Michigan Condition? With no research array or table of some type, 'msu' is just like your registration form could possibly get.

Alternatively, you can give a drop lower that consists of all schools and also have the user choose one, however again you are still turning to typing out all the college names.


This link will let you: List of edu Domains

I am unfamiliar with .edu top level domain names however i presume registrants are needed to supply valid information within their whois records, so a normal whois search might be a beginning point. For example, http://whois.domaintools.com/stanford.edu shows this:


   Stanford University
   The Board of Trustees of the Leland Stanford Junior University
   241 Panama Street, Pine Hall, Room 115
   Stanford, CA 94305-4122

Obviously, the issue is getting a search provider which will accept automated queries.