note 106679 modified in book.imap by thiago
| From: | thiago@php.net | Date: | Mon, 28 Nov 2011 03:36:14 +0000 |
| Subject: | note 106679 modified in book.imap by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184697@lists.php.net to get a copy of this message | ||
Because I don't know regular expressions, I hacked the mail_parse_headers() to properly get the
last line from the header string:
<?php
function mail_parse_headers($headers)
{
$headers=preg_replace('/\r\n\s+/m', '',$headers);
$headers=trim($headers)."\r\n"; /* a hack for the preg_match_all in the next line */
preg_match_all('/([^: ]+): (.+?(?:\r\n\s(?:.+?))*)?\r\n/m', $headers, $matches);
foreach ($matches[1] as $key =>$value) $result[$value]=$matches[2][$key];
return($result);
}
?>
--was--
Because I don't know regular expressions, I hacked the mail_parse_headers() to properly get the
last line from the header string:
function mail_parse_headers($headers)
{
$headers=preg_replace('/\r\n\s+/m', '',$headers);
$headers=trim($headers)."\r\n"; /* a hack for the preg_match_all in the next line */
preg_match_all('/([^: ]+): (.+?(?:\r\n\s(?:.+?))*)?\r\n/m', $headers, $matches);
foreach ($matches[1] as $key =>$value) $result[$value]=$matches[2][$key];
return($result);
}
http://php.net/manual/en/book.imap.php