Uncategorized

php extract email from string

function extract_email_address ($string) { $emails = array(); $string = str_replace(“\r\n”,’ ‘,$string); $string = str_replace(“\n”,’ ‘,$string); foreach(preg_split(‘/ /’, $string) as $token) { $email = filter_var($token, FILTER_VALIDATE_EMAIL); if ($email !== false) { $emails[] = $email; } } return $emails; }