How to get email address from a long string

前端 未结 13 1983
情书的邮戳
情书的邮戳 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:45

    If it's really space-separated:

    php > $matches = array();
    php > preg_match('/^[^ ]*/', $string, $matches);
    php > print_r($matches[0]);
    user@domain.com
    

提交回复
热议问题