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

前端 未结 7 1373
孤城傲影
孤城傲影 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 05:05

    Strip the address to the basic form before comparing. Make a function normalise() that will strip the label, then remove all dots. Then you can compare the addresses via:

    normalise(address1) == normalise(address2)
    

    If you have to do it very often, save the addresses in the normalised form too, so you don't have to convert them back too often.

提交回复
热议问题