Email Code

  Home arrow Email Code arrow Get Email Addresses from Strings
EMAIL CODE

Get Email Addresses from Strings
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    2003-11-19

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    For you guys who needs to grab email addresses either from string or from a web page you've grab. Here is the code.

    By : hermawan

    <?php
    /*
    Snippet Name: Get Emails from Strings
    Author : Hermawan Haryanto
    Email : hermawan@codewalkers.com
    Homepage: http://hermawan.com
    Blog : http://hermawan.codewalkers.com
    */

    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 = "test test@test.com ha ha heHe@test.com bla bla bla@test.com";

    # Get the emails on arrays;
    $emails = get_emails ($str);

    # Print that arrays;
    print_r ($emails);
    ?>
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Email Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    EMAIL CODE ARTICLES

    - Basic Ajax contact form
    - Random validation image
    - tinySendMail
    - SaferMail 0.7
    - Smtp Auth Email Script
    - Search Mime Email Structure
    - PHP Text / HTML Email with Attachments 2.1
    - Simple way to send mail wih one attached Doc...
    - Generic POP3 Class
    - PHP Text / HTML Email with Unlimited Attachm...
    - Another SendMail
    - email with attachment
    - Get Email Addresses from Strings
    - EmailCode
    - Email Validation - Gone Wild

    Developer Shed Affiliates

     



    © 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap