php extract email address from string
<?php
$string = 'Ruchika < [email protected] >';
$pattern = '/[a-z0-9_\-\+\.]+@[a-z0-9\-]+\.([a-z]{2,4})(?:\.[a-z]{2})?/i';
preg_match_all($pattern, $string, $matches);
var_dump($matches[0]);
?>
php extract email address from string
<?php
$string = 'Ruchika < [email protected] >';
$pattern = '/[a-z0-9_\-\+\.]+@[a-z0-9\-]+\.([a-z]{2,4})(?:\.[a-z]{2})?/i';
preg_match_all($pattern, $string, $matches);
var_dump($matches[0]);
?>
php extract email from string
<?php
function fetch_mails($text){
//String that recognizes an e-mail
$str = '/([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i';
preg_match_all($str, $text, $out);
//return a blank array if not true otherwise insert the email in $out and return
return isset($out[0]) ? $out[0] : array();
}
//string to be checked
$tstr = '
My first e-mail address is [email protected]
My second e-mail address is [email protected]
Obviously this is not a emaail address: code__speedy@^gmail.co.in
';
//display email addresses
echo"<pre>";
print_r(fetch_mails($tstr));
?>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us