How to check for a duplicate email address in PHP, considering Gmail (user.name+label@gmail.com)

前端 未结 7 1410
孤城傲影
孤城傲影 2021-01-01 04:48

How can I check for duplicate email addresses in PHP, with the possibility of Gmail\'s automated labeler and punctuation in mind?

For example, I wan

7条回答
  •  独厮守ぢ
    2021-01-01 04:51

    $email_parts    = explode('@', $email);
    
    // check if there is a "+" and return the string before
    $before_plus    = strstr($email_parts[0], '+', TRUE);
    $before_at      = $before_plus ? $before_plus : $email_parts[0];
    
    // remove "."
    $before_at      = str_replace('.', '', $before_at);
    
    $email_clean    = $before_at.'@'.$email_parts[1];
    

提交回复
热议问题