Created
January 13, 2012 18:54
-
-
Save fomigo/1608065 to your computer and use it in GitHub Desktop.
Example of parsing strings of emails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$string = 'first@mail.ru=From first||second@mail.ru=From second'; | |
$mails = explode('||', $string); | |
$to = array(); | |
foreach ($mails as $mail) { | |
list($key, $value) = explode('=', $mail); | |
$to[trim($key)] = trim($value); | |
} | |
var_dump($to); | |
/* | |
$string = 'fomigo@inbox.ru,phomigo@yahoo.com'; | |
$mails = explode(',', $string); | |
$to = array(); | |
foreach ($mails as $mail) { | |
$to[trim($mail)] = 'Site name'; | |
} | |
// var_dump($to); | |
echo '<pre>', print_r($to, 1), '</pre>'; | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment