php - Validate email and ban certain domains
943
I have this code I currently use to validate emails:
return (bool) preg_match('/^([a-z0-9\+\_\-\.]+)@([a-z0-9\+\_\-\.]{2,})(\.[a-z]{2,4})$/i', $arg0);
How can I modify that code so I can ban several domains? I don't want any extra files to add, just to modify this code.
Thank you.
Answer
Solution:
The easiest way would be to have an array with banned providers:
$providers = Array ( 'gmail.com', 'yahoo.com' );
and then just loop trough that array and check if provided email contains
'@' . $provider
.