<?php
function get_emails ($str)
{
$emails = array();
preg_match_all("/\b\w+\@\w+[\.\w+]+\b/", $str, $output);
foreach($output[0] as $email) array_push ($emails, strtolower($email));
if (count ($emails) >= 1) return $emails;
else return false;
}
# Here is how to use it.
# Sample string containing email addresses;
$str = "happy happy@gmail.com bingo happy@test.com jojo jojo@badjojo.com";
# Get the emails on arrays;
$emails = get_emails ($str);
# Print that arrays;
print_r ($emails);
?>
Output
Array ( [0] => happy@gmail.com [1] => happy@test.com [2] => jojo@badjojo.com )
Now I have given enough tips try some experimenting lust of yours and utilize it according to your need.
No comments:
Post a Comment