On Thu, 25 Jul 2002 05:47:57 +0200, you wrote:

>Bonus points if you could tell me a way to parse the entire headers
>into something useful like a set of key, value pairs using the header
>name as key and the value as value. 

$lines = split("\r?\n",$headerstring);

foreach($lines as $line) {
  if(preg_match("/^([^:]+):\s*(.*)$/",$line,$matches)) {
    $headers[$matches[1]] = $matches[2];
  }
}

I think IMAP headers are split on newlines only, but I don't know if
some Windoze servers (such as Exchange) put CRLF in there or not.  The
regex above should work, assuming that everything before the first
colon is the header name and everything after it is the value.  I
haven't read the RFC in detail so there may be a better pattern to
match against than the one above.  That is assuming that the above
pattern works, I haven't tested it.  HTH.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to