if I have a string of key-> value pairs in the following format:
MIME-Version: 1.0 From: "Tim Lincecum" Reply-To: "Tim Lincecum" Return-path: "Tim Lincecum" Content-Type: text/html; charset=iso-8859-1 Subject: Giants Win World Series!
How do I get an array such that arr['From'] = "Tim Lincecum", etc
I know there's the explode function, but the only delimiter I see (colon) is in the middle of a key and a value rather than between each pair. How can I approach this?
EDIT:
With zerkms' help suggesting there should actually be a newline, I came up with this:
$arr = array();
$temp = explode("\r\n",$data['headers']);
foreach ($temp as $pair) {
list($key,$value) = explode(': ',$pair);
$arr[$key]=str_replace("\"","",$value);
}