Created
November 28, 2010 06:06
-
-
Save shelbyKiraM/718649 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* breakapart | |
* | |
* @return array | |
* @author Shelby Munsch | |
**/ | |
function breakapart(string $combinedstring) | |
{ | |
$return = array("name", "email"); | |
// match only the email address | |
$email = preg_match("[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}", $combinedstring); | |
// strips the email address and any left over quotes from the string. what's left should be just the name | |
$name = preg_replace("\"", "", preg_replace("(<)?[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}(>)?", "", $combinedstring)); | |
$return['name'] = $name; | |
$return['email'] = $email; | |
return $return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment