Advertisement
Guest User

Untitled

a guest
Mar 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. "a1 b.d"<a1@test.com>,
  2. <a2@test.com>,
  3. "a3 b.d"<a3@test.com> ,
  4. a4@test.com ,
  5.  
  6. a1@test.com,
  7. a2@test.com,
  8. a3@test.com,
  9. a4@test.com,
  10.  
  11. function extractEmail( $data )
  12. {
  13. if ( preg_match( "/[^@s]+@([-a-z0-9]+.)+[a-z]{2,}/i", $data, $email ) )
  14. {
  15. $replacement = '<a href="mailto:' . $email[ 0 ] . '" target="_blank">' . $email[ 0 ] . '</a> ';
  16. $data = preg_replace( "/[^@s]+@([-a-z0-9]+.)+[a-z]{2,}/i", $replacement, $data );
  17. }
  18. return $data;
  19. }
  20.  
  21. <?php
  22. echo extractEmail("Some text goes here before mail@mail.com and some text here goes after");
  23. ?>
  24.  
  25. function extract_emails_from($string) {
  26. preg_match_all("/[._a-zA-Z0-9-]+@[._a-zA-Z0-9-]+/i", $string, $matches);
  27. return $matches[0];
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement