How to check if an email from an educational institution?

This PHP snippet (function) allows you to check if an email address from an educational institution.

 * @title          Check if it is a valid and university email address.
 * @param          string $sEmail
 * @return         boolean
function isUniversityEmail($sEmail)
    return preg_match('/^[a-z0-9_\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]+\.)+edu$/i', $sEmail);

Example of usage:

if (!isUniversityEmail(''))
    exit('You must have a valid and .edu email address to register for an account.');

Good code! ;-)

Next entry

Previous entry

Similar entries

comments powered by Disqus