sldhana Posted December 27, 2008 Share Posted December 27, 2008 I am trying to read a particular response header posted by cURL and I am not too sure on how to go about doing this,. This is a sample header I get: HTTP/1.1 200 OK Date: Sat, 27 Dec 2008 04:15:59 GMT Server: Microsoft-IIS/6.0 Set-Cookie: JSESSIONID=21EDA47891D6A4B337AB8E1EB136306E; Path=/StgWeb; Secure Cache-Control: no-cache Pragma: no-cache Expires: 0 Payment-Verified: TRUE Content-Type: text/html Content-Length: 0 What I need is to read the Payment Verified line. Is there an easy way to do this? Or I have to break the response by it's new lines? Quote Link to comment Share on other sites More sharing options...
chronister Posted December 27, 2008 Share Posted December 27, 2008 <?php $header = <<<HEADER HTTP/1.1 200 OK Date: Sat, 27 Dec 2008 04:15:59 GMT Server: Microsoft-IIS/6.0 Set-Cookie: JSESSIONID=21EDA47891D6A4B337AB8E1EB136306E; Path=/StgWeb; Secure Cache-Control: no-cache Pragma: no-cache Expires: 0 Payment-Verified: FALSE Content-Type: text/html Content-Length: 0 HEADER; $hArray = explode("\n",$header); echo (in_array('Payment-Verified: TRUE',$hArray)) ? 'Payment was verified' : ''; echo (in_array('Payment-Verified: FALSE', $hArray)) ? 'Payment was not verified' : ''; ?> Since I know nothing about regex, here would be my solution. I am assuming that a non-verified payment would simply return false. Nate Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 27, 2008 Share Posted December 27, 2008 You might want to look at the http_parse_headers function. Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.