The standard PHP way to test whether a string $str ends with a substring $test is:
$str
$test
$endsWith = substr( $str, -strlen( $test ) ) ==
easiest way to check it via regular expression
for example to check if the mail given is gmail:
echo (preg_match("/@gmail\.com$/","example-email@gmail.com"))?'true':'false';