- preg_match: documentation ( source)
- print_r: documentation ( source)
- preg_quote: documentation ( source)
<?php
$user_email = "dbutt@westminstertoyota.com";
$allowed_domain = '/^[^@]+@[^@]*toyota[^@]*\.[^@]+/';
preg_match($allowed_domain, $user_email, $matches);
print_r($matches);
$regex = preg_quote($allowed_domain, '#') . '$';
if (preg_match("#$regex#i", $user_email) or preg_match($pattern, $allowed_domain))
{
echo 'True';
}else{
echo 'False';
}