--- Mike Brandonisio <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to flag and mask emails from a text string. I found this
> on Zend but cannot get it to work. It is supposed to create an array
> of email addresses but I think there is something wrong in the
> 'preg_match_all' call for the pattern. I cannot figure out if this
> pattern is even correct.
>
> function get_emails ($str)
> {
> $emails = array();
> preg_match_all("/[EMAIL PROTECTED]/", $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 = "test [EMAIL PROTECTED] ha ha [EMAIL PROTECTED] bla bla [EMAIL
> PROTECTED]";
>
> # Get the emails on arrays;
> $emails = get_emails ($str);
>
> # Print that arrays;
> print_r ($emails);
>
> Sincerely,
> Mike
Try this:
preg_match_all("/[EMAIL PROTECTED]/", $str, $output);
James Keeline