この種の文字列を分割して、電子メールを< >より小さいものとより大きいものに分ける必要があります。regex
次のとを試していpreg_split
ますが、うまくいきません。
"email1@domain.com" <email1@domain.com>
News <news@e.domain.com>
Some Stuff <email-noreply@somestuff.com>
期待される結果は次のようになります。
Array
(
[0] => "email1@domain.com"
[1] => email@email.com
)
Array
(
[0] => News
[1] => news@e.domain.com
)
Array
(
[0] => Some Stuff
[1] => email-noreply@somestuff.com
)
私が現在使用しているコード:
foreach ($emails as $email)
{
$pattern = '/<(.*?)>/';
$result = preg_split($pattern, $email);
print_r($result);
}