Skip to content

Instantly share code, notes, and snippets.

@fomigo
Created January 13, 2012 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fomigo/1608065 to your computer and use it in GitHub Desktop.
Save fomigo/1608065 to your computer and use it in GitHub Desktop.
Example of parsing strings of emails
<?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