Anyway what this little function does is read only the headers of a page using PhP's curl() functions and returns them as an associative array. A great way to check if you need to update an RSS cache or something similar.
function checkHeaders($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
$content = curl_exec($ch);
curl_close($ch);
preg_match_all('/[^:]*[\r\n]|([^:]*):(.*)[\r\n]/', $content, $matches, PREG_SET_ORDER);
foreach ( $matches as $match ) {
if ( !empty($match[0]) ) {
if( strstr($match[0], 'HTTP') === false )
$headers[$match[1]] = $match[2];
else
$headers['HTTP'] = $match[0];
}
}
return $headers;
}
The HTTP header index will simply be 'HTTP' every other header will be in the form <header> => <value>.
example:
['Content-Type'] => ['text/xml']
enjoy :)