Last active
August 29, 2015 14:04
-
-
Save rxnlabs/9e135bf6deb90eb7340a to your computer and use it in GitHub Desktop.
PHP - get headers from cURL request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_headers_curl($response){ | |
$headers = array(); | |
$header_text = substr($response, 0, strpos($response, "\r\n\r\n")); | |
foreach (explode("\r\n", $header_text) as $i => $line){ | |
if ($i === 0) | |
$headers['http_code'] = $line; | |
else{ | |
list ($key, $value) = explode(': ', $line); | |
$headers[$key] = $value; | |
} | |
} | |
return $headers; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment