Return to Snippet

Revision: 2192
at January 12, 2007 12:55 by gdonald


Initial Code
error_reporting( E_ALL );

function is_valid_email( $email )
{
  return preg_match( '/[.+a-zA-Z0-9_-]+@[a-zA-Z0-9-]+.[a-zA-Z]+/', $email );
}

$emails = array(  'br0k3n',
                  '[email protected]',
                  '[email protected]',
                  '[email protected]',
                  '[email protected]' );

foreach( $emails as $email )
{
  echo $email . ' is' . ( is_valid_email( $email ) ? '' : ' not' )  . " valid\n";
}

Initial URL


Initial Description


Initial Title
PHP Valid Email

Initial Tags
regex, email, php

Initial Language
PHP