我相信你现在已经找到了解决办法,但为了完整起见...
基本上你需要存储的本地部分为是,不剥点了,后来带比较时,应用程序和注册表中的点都会出现。像:
$registered_emails[0]="[email protected]"; //This is just to show how it was registered first time
$application_email="[email protected]"; //New application email
$discard=0; //flag for discarding application
if (preg_match("/@gmail.com$/i", $application_email)===1) {
$app_em=str_replace(".", "", $application_email);
foreach ($registered_emails as $reg_em)
if ($app_em==str_replace(".", "", $reg_em)) {
// "[email protected]"=="[email protected]"
$discard=1; // discard application
break;
}
//can't use an "else" clause here to break, as you need to loop through all registries
}
if ($discard==1)
echo "discard application";
else
array_push($registered_emails, $application_email); //register $application_email as is ([email protected])
也许它可能是值得之前过滤掉列表中的所有Gmail里的邮件,甚至存储所有的Gmail电子邮件待用;肯定不是最优雅的解决方案,但可能是最快的一个