The FILTER_SANITIZE_EMAIL filter removes all illegal characters from an email address.
Remove all illegal characters from an email address:
Example:
<?php
// Variable to check
$email = “john(.doe)@exa//mple.com”;
// Remove all illegal characters from email
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
echo $email;
?>
Output: