Sunday, 15 January 2012

php - Separate email address from given string format -



php - Separate email address from given string format -

i have next type of info in txt format , there hundreds of lines below. how fetch emails them.

email1@yahoo.com,us,wolterman,http://www.example.com/profile.php?id=12 email2@yahoo.com,uk,superman,http://www.example.com/profile.php?id=21

here 1 way if addresses first.

$text = <<<data email1@yahoo.com,us,wolterman,http://www.example.com/profile.php?id=12 email2@yahoo.com,uk,superman,http://www.example.com/profile.php?id=21 email3@yahoo.com,us,wolterman,http://www.example.com/profile.php?id=12 email4@yahoo.com,uk,superman,http://www.example.com/profile.php?id=21 email5@yahoo.com,us,wolterman,http://www.example.com/profile.php?id=12 email6@yahoo.com,uk,superman,http://www.example.com/profile.php?id=21 data; preg_match_all('~^[^,]+~m', $text, $matches); echo implode("\n", $matches[0]);

output

email1@yahoo.com email2@yahoo.com email3@yahoo.com email4@yahoo.com email5@yahoo.com email6@yahoo.com

php regex

No comments:

Post a Comment