How to get email address from a long string

前端 未结 13 1960
情书的邮戳
情书的邮戳 2020-11-27 04:29

In PHP, I have a string like this:

$string = \"user@domain.com MIME-Version: bla bla bla\";

How do i get the email address only? Is there a

13条回答
  •  [愿得一人]
    2020-11-27 04:54

    If you're not sure which part of the space-separated string is the e-mail address, you can split the string by spaces and use

    filter_var($email, FILTER_VALIDATE_EMAIL)
    

    on each substring.

提交回复
热议问题