note 90950 deleted from function.stripos by danbrown

From: Date: Wed, 29 Jun 2011 18:51:33 +0000
Subject: note 90950 deleted from function.stripos by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181069@lists.php.net to get a copy of this message
Note Submitter: manualregexp ---- Fast email validator using stripos to check for valid characters. <?php function validate_email($value) { $chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ". "abcdefghijklmnopqrstuvwxyz0123456789@._"; $at=0; /* at sign */ $dot=0; /* dot after at */ $end_pos = strlen($value)-1; for ($i=0;$i<strlen($value);$i++) { $c = $value[$i]; if (stripos($chars, $c)===false) return false; if ($c=="@") $at++; if ($at==1 && $c==".") $dot++; if ($at>1) return false; /* Don't start or end with an '@' or a '.' * No @'s or .'s next to each other. */ if (($c=="." || $c=="@") && ($i==0 || $i==$end_pos || $prev_c=="." || $prev_c=="@")) return false; $prev_c=$c; } return ($at==1 && $dot>0); } ?>

« previous php.notes (#181069) next »