Skip to content

Instantly share code, notes, and snippets.

@tomsseisums
Created December 21, 2011 12:11
Show Gist options
  • Save tomsseisums/1505803 to your computer and use it in GitHub Desktop.
Save tomsseisums/1505803 to your computer and use it in GitHub Desktop.
PHP and headers and... aye, it sucks
<?php
// a function to check if a specific header exists, current way due to headers_list() returning numeric array
function header_exists($lookup)
{
$headers = headers_list();
foreach($headers as $header){
if(0 !== stripos($header, $lookup)){ // or other lookup...
continue;
}else{
return true;
}
}
return false;
}
// what if the function would return headers in a key => value fashion?
function header_exists($lookup)
{
return array_key_exists($lookup, headers_list());
}
// the thing is that, AFAIK, every single header follows the `Key: Value` pattern, why such a weird result?
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment