PHP Find Emails Address in Text
Use this PHP function to find email addresses in a given string.
<?php
function find_emails($string)
{
$regex = '/\S+@\S+\.\S+/';
preg_match_all($regex, $string, $emails, PREG_PATTERN_ORDER);
return $emails[0];
}
$string = "Lorem ipsum dolor sit@gmail.com amet, consectetur adipiscing elit, sed do@gmail.com eiusmod tempor incididunt ut labore et dolore magna aliqua.";
$filter = find_emails($string);
print_r($filter);
?>