Well, here is a very simple way to do this, the VALID-email address should contain only one @ character, so as a test you can just blow up the string at @ and collect the second segment.
Example:
if (filter_var($user_email, FILTER_VALIDATE_EMAIL)) { //Valid Email: $parts = explode("@",$user_email); /* * You may want to use in_array if you already have a compiled array * The switch statement is mainly used to show visually the check. */ switch(strtolower($parts[1])) { case 'facebook.com': case 'gmail.com': case 'googlemail.com': //Do Something break; default: //Do something else break; } }
source share