Page 1 of 1

HTTP Header Break-up

Posted: Thu May 11, 2006 10:03 am
by buttsp
Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have the following HTTP header in a string:

Code: Select all

HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Expires: -1 Pragma: no-cache Cache-Control: no-cache Set-Cookie: JSESSIONID=CAE33EFD720A61637EABA03468F7B67B; Path=/travelsearch Content-Type: text/xml;charset=ISO-8859-1 Content-Length: 97 Date: Thu, 11 May 2006 14:54:48 GMT
What i want is to break the above string into pieces and store it into an array like the following:

Code: Select all

$newHeader[0]  = HTTP/1.1 200 OK : HTTP/1.1 200 OK
$newHeader[1]  = Server : Apache-Coyote/1.1
$newHeader[2]  = Expires : -1
$newHeader[3]  = Pragma : no-cache 
...
..
..
Pls help....


Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu May 11, 2006 12:49 pm
by Burrito
you'll probably need a regular expression and preg_match() to accomplish that as there are no consistent 'split points'.