note 90950 added to function.stripos

From: Date: Mon, 18 May 2009 10:52:55 +0000
Subject: note 90950 added to function.stripos
Groups: php.notes 
Request: Send a blank email to php-notes+get-155662@lists.php.net to get a copy of this message
Fast email validator using stripos to check for valid characters. 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); } ---- Server IP: 64.71.164.2 Probable Submitter: 80.101.185.11 ---- Manual Page -- http://www.php.net/manual/en/function.stripos.php Edit -- https://master.php.net/note/edit/90950 Del: integrated -- https://master.php.net/note/delete/90950/integrated Del: useless -- https://master.php.net/note/delete/90950/useless Del: bad code -- https://master.php.net/note/delete/90950/bad+code Del: spam -- https://master.php.net/note/delete/90950/spam Del: non-english -- https://master.php.net/note/delete/90950/non-english Del: in docs -- https://master.php.net/note/delete/90950/in+docs Del: other reasons-- https://master.php.net/note/delete/90950 Reject -- https://master.php.net/note/reject/90950 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#155662) next »