note 82339 added to function.imap-fetchheader
| From: | Jille at nomorecrap dot quis dot cx | Date: | Sun, 06 Apr 2008 22:15:39 +0000 |
| Subject: | note 82339 added to function.imap-fetchheader | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137989@lists.php.net to get a copy of this message | ||
<?PHP
$headers=imap_fetchheader($imap, $msgid);
preg_match_all('/([^: ]+): (.+?(?:\r\n\s(?:.+?))*)\r\n/m', $headers, $matches);
?>
Works quite well for splitting headers,
$matches will contain 3 arrays:
$matches[0] are the full-lines (To: Jille@devnull.quis.cx\r\n)
$matches[1] will be the header (To)
$matches[2] will be the value (Jille@devnull.quis.cx)
In multi-line values the 'multilining is not stripped!'
this could be achieved with something like:
<?PHP
preg_replace('/\r\n\s+/m', '', $matches[2]);
?>
----
Server IP: 195.184.64.198
Probable Submitter: 82.174.113.83
----
Manual Page -- http://www.php.net/manual/en/function.imap-fetchheader.php
Edit -- https://master.php.net/note/edit/82339
Del: integrated -- https://master.php.net/note/delete/82339/integrated
Del: useless -- https://master.php.net/note/delete/82339/useless
Del: bad code -- https://master.php.net/note/delete/82339/bad+code
Del: spam -- https://master.php.net/note/delete/82339/spam
Del: non-english -- https://master.php.net/note/delete/82339/non-english
Del: in docs -- https://master.php.net/note/delete/82339/in+docs
Del: other reasons-- https://master.php.net/note/delete/82339
Reject -- https://master.php.net/note/reject/82339
Search -- https://master.php.net/manage/user-notes.php