- filter_var: documentation ( source)
<?php
$emails = array(
'wouter@foobar.nl',
'bas@iets.net',
'nienke@localhost',
'kees__@foo.com',
'@bar.com',
);
foreach ($emails as $email) {
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "{$email} is ongeldig\n";
}
}