Re: Grab value of mail headers

From: Date: Fri, 26 Jul 2002 16:49:31 +0000
Subject: Re: Grab value of mail headers
Groups: php.general 
Request: Send a blank email to php-general+get-109810@lists.php.net to get a copy of this message
>Hi > >Could someone please enlighten me on a good way to grab the value for >a given mail header once I've fetched the entire headers to a string >using php:s imap_fetchheader() function? > >For an example I would like to look for a header called List-Id which >may look like this: > >List-Id: <php-general.lists.php.net> > >And grab the value - <php-general.lists.php.net> - into a variable to >use later on in my script. > >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. Assuming they start as just one big long string, and that it's just like regular email headers: <?php # Work with stupid servers that don't follow spec wrt \r\n: $headers = str_replace("\r\n", "\n", $headers); $headers = explode("\n", $headers); while (list(,$header) = each($headers)){ $parts = explode(":", $header); $key = $parts[0]; # Allow for : to appear later in this header: unset($parts[0]); $value = implode(":", $parts); $header_array[$key] = $value; } ?> -- Like Music? http://l-i-e.com/artists.htm I'm looking for a PRO QUALITY two-input sound card supported by Linux (any major distro). Need to record live events (mixed already) to stereo CD-quality. Soundcard Recommendations? Software to handle the recording? Don't need fancy mixer stuff. Zero (0) post-production time. Just raw PCM/WAV/AIFF 16+ bit, 44.1KHz, Stereo audio-to-disk.

« previous php.general (#109810) next »