我相信你現在已經找到了解決辦法,但爲了完整起見...
基本上你需要存儲的本地部分爲是,不剝點了,後來帶比較時,應用程序和註冊表中的點都會出現。像:
$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電子郵件待用;肯定不是最優雅的解決方案,但可能是最快的一個