Skip to content

Instantly share code, notes, and snippets.

@jamesrwhite
Created December 9, 2012 14:18
Show Gist options
  • Select an option

  • Save jamesrwhite/4245135 to your computer and use it in GitHub Desktop.

Select an option

Save jamesrwhite/4245135 to your computer and use it in GitHub Desktop.
cURL Headers
<?php
$curl = curl_init('http://123123123123123123123123213w.com');
curl_setopt_array($curl, array(
CURLOPT_HEADER => true,
CURLOPT_NOBODY => true,
CURLOPT_RETURNTRANSFER => true,
));
// Get the headers
$headers = curl_exec($curl);
// Split by new lines into an array
$headers = explode(PHP_EOL, $headers);
// Remove empty lines
$headers = array_filter($headers, function($value) {
return !empty($value) and !in_array($value, array("\r", "\n"));
});
print_r($headers);
@jamesrwhite
Copy link
Author

Weird. For me it's an empty array. I've tried from my laptop and vps as well.

@PatrickSocha
Copy link

May try reinstall php again, see if that solves the problem. Thanks for the help :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment