HTTP Header Break-up

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
buttsp
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 9:17 am

HTTP Header Break-up

Post 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]
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you'll probably need a regular expression and preg_match() to accomplish that as there are no consistent 'split points'.
Post Reply