I have following problem: I make a cURL request and get a response like this (no json):
100
123456
Foo: Bar
Foo1: Bar1
Foo2: Bar2
To be able to work with that data, I create an array:
$result = preg_split("/\\r\\n|\\r|\\n/", $result);
Now I have an array with these items:
array(
"100",
"123456",
"Foo: Bar",
"Foo1: Bar1",
"Foo2: Bar2"
)
My question is: Is there a nice way to create an array with key => value pairs, so the strings before the colons are the keys and the ones after the colons the values? The first two items never have colons, so I need to add a key to them separately and the string before the colons is never the same, so it isn't possible that there is the same key multiple times. Also, there's either just one or no colon.
Thanks in advance!