Skip to content

Instantly share code, notes, and snippets.

View eskrano's full-sized avatar
🇺🇦
Focusing

alex eskrano

🇺🇦
Focusing
View GitHub Profile
@vrushank-snippets
vrushank-snippets / Extract emails from a string
Created March 23, 2012 10:59
PHP : Extract emails from a string
function extract_emails($str){
// This regular expression extracts all emails from a string:
$regexp = '/([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i';
preg_match_all($regexp, $str, $m);
return isset($m[0]) ? $m[0] : array();
}
$test_string = 'This is a test string...