Php extract email from string

    Table of contents
  • Extract email address from string - php
  • PHP Extract email address from a string [closed]
  • How to extract email addresses from a string in PHP?
$to = 'Wez Furlong , [email protected]';
var_dump[mailparse_rfc822_parse_addresses[$to]];
array[2] {
  [0]=>
  array[3] {
    ["display"]=>
    string[11] "Wez Furlong"
    ["address"]=>
    string[15] "[email protected]"
    ["is_group"]=>
    bool[false]
  }
  [1]=>
  array[3] {
    ["display"]=>
    string[15] "[email protected]"
    ["address"]=>
    string[15] "[email protected]"
    ["is_group"]=>
    bool[false]
  }
}
function extract_emails_from[$string]{
    preg_match_all[ '/[[\w+\.]*\[email protected][\w+\.]*\w+[\w+\-\w+]*\.\w+]/is', $string, $matches ];
    return $matches[0];
};
function extract_emails_from[$string]{
  preg_match_all["/[\._a-zA-Z0-9-][email protected][\._a-zA-Z0-9-]+/i", $string, $matches];
  return array_values[array_unique[$matches[0]]];
}

Bài mới nhất

Chủ Đề