public static function emailToLink($text)
    {
        preg_match_all("/([\\\a-z0-9_\-\.]+)@([a-z0-9-]{1,64})\.([a-z]{2,10})/iu", $text, $emails);

        foreach ($emails[0] as $email) {
            $email = trim($email);

            if ($email[0] == '\\') {
                $text = str_replace($email, mb_substr($email, 1), $text);
            } else {
                $text = str_replace($email, static::emailObfuscator($email), $text);
            }
        }

        return $text;
    }
public static function emailToLink($text)
    {
        preg_match_all("/([\\\a-z0-9_\-\.]+)@([a-z0-9-]{1,64})\.([a-z]{2,10})/iu", $text, $emails);

        foreach ($emails[0] as $email) {
            $email = trim($email);

            if ($email[0] == '\\') {
                $text = str_replace($email, mb_substr($email, 1), $text);
            } else {
                $text = str_replace($email, static::emailObfuscator($email), $text);
            }
        }

        return $text;
    }
public static function emailToLink ( $ text ) { preg_match_all ( "/([\\\a-z0-9_\-\.]+)@([a-z0-9-]{1,64})\.([a-z]{2,10})/iu" , $ text , $ emails ) ; foreach ( $ emails [ 0 ] as $ email ) { $ email = trim ( $ email ) ; if ( $ email [ 0 ] == '\\' ) { $ text = str_replace ( $ email , mb_substr ( $ email , 1 ) , $ text ) ; } else { $ text = str_replace ( $ email , static :: emailObfuscator ( $ email ) , $ text ) ; } } return $ text ; }
Convert any email to a "mailto" link.

Escape character is `\`. For example, "\demo@email.com" won't be converted
to link.

@param string $text The text where to look for emails addresses
@return string
Convert any email to a mailto link .