In this tutorial we will discuss how to extract email addresses using php.
You need to pass the string (e.g. the body of an email) to the function, and it will returns an array of Email Addresses listed in the String.
function extract_emails_from($string) {
preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);
return $matches[0];
}
If you get the return value of function in $emails, you can parsing it using foreach:
foreach($emails as $email) {
echo trim($email).'<br/>';
}
Have Fun !
0 Comments