find emails in text

    0

    0

    jvit
    array(2) {
      [0]=>
      string(23) "tan.987@gmail.com.vnx"
      [1]=>
      string(12) "do@gmail.com"
    }
    

    Shortcut: str.findEmails

    /**
    * Find Emails Address in Text
    *
    * @return array
    */
    function findEmails($string)
    {
      $regex = '/\S+@\S+\.\S+/';
      preg_match_all($regex, $string, $emails,  PREG_PATTERN_ORDER);
      return $emails[0];
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.