由于你正在处理电子邮件地址,你确信,你需要一定的灵活性,才能处理你如何展示其结果,而不只是躲藏各党派。
I would recommend http://php.net/mailparse_rfc822_parse_addresses
$email = mailparse_rfc822_parse_addresses("Christian Eric Paran <[email protected]>") ;
echo $email[0][ display ] ; // Christian Eric Paran
echo $email[0][ address ] ; // [email protected]
如果你没有邮局,你可以使用。
$email = parse_addresses ( "Christian Eric Paran <[email protected]>" );
echo $email [ display ]; // Christian Eric Paran
echo $email [ address ]; // [email protected]
职能
function parse_addresses($address) {
$info = array ();
preg_match_all ( /s*"?([^><,"]+)"?s*((?:<[^><,]+>)?)s*/ , $address, $matches );
$info [ display ] = $matches [1] [0];
$info [ address ] = str_replace ( array (
"<",
">"
), "", $matches [2] [0] );
return $info;
}