<?php
// input: My Test Email <some.test.email@somewhere.net>
function get_displayname_from_rfc_email($rfc_email_string) {
// match all words and whitespace, will be terminated by '<'
$name = preg_match('/[\w\s]+/', $rfc_email_string, $matches);
$matches[0] = trim($matches[0]);
return $matches[0];
}
// Output: My Test Email
function get_email_from_rfc_email($rfc_email_string) {
// extract parts between the two parentheses
$mailAddress = preg_match('/(?:<)(.+)(?:>)$/', $rfc_email_string, $matches);
return $matches[1];
}
// Output: some.test.email@somewhere.net
?>