Guest User

Untitled

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