Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "a1 b.d"<a1@test.com>,
- <a2@test.com>,
- "a3 b.d"<a3@test.com> ,
- a4@test.com ,
- a1@test.com,
- a2@test.com,
- a3@test.com,
- a4@test.com,
- function extractEmail( $data )
- {
- if ( preg_match( "/[^@s]+@([-a-z0-9]+.)+[a-z]{2,}/i", $data, $email ) )
- {
- $replacement = '<a href="mailto:' . $email[ 0 ] . '" target="_blank">' . $email[ 0 ] . '</a> ';
- $data = preg_replace( "/[^@s]+@([-a-z0-9]+.)+[a-z]{2,}/i", $replacement, $data );
- }
- return $data;
- }
- <?php
- echo extractEmail("Some text goes here before mail@mail.com and some text here goes after");
- ?>
- function extract_emails_from($string) {
- preg_match_all("/[._a-zA-Z0-9-]+@[._a-zA-Z0-9-]+/i", $string, $matches);
- return $matches[0];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement