title: PHP cURL - Link Header
body: <p>I've made a code search application that interacts with GitHubs API, that i want to add pagination to, pagination data is held in the header like so:</p>
  
  <p><code>Link: &lt;https://api.github.com/user/repos?page=3&amp;per_page=100&gt;; rel="next",
    &lt;https://api.github.com/user/repos?page=50&amp;per_page=100&gt;; rel="last"</code> </p>
  
  <p>My code:</p>
  
  <pre><code>    // API CONNECTION
      $url = 'https://api.github.com/search/code?q=' . $term  . '+language:' . $lang . '&amp;per_page=' . $pp;
      $cInit = curl_init();
      curl_setopt($cInit, CURLOPT_URL, $url);
      curl_setopt($cInit, CURLOPT_RETURNTRANSFER, 1); // 1 = TRUE
      curl_setopt($cInit, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); 
      curl_setopt($cInit, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
      curl_setopt($cInit, CURLOPT_USERPWD, $user . ':' . $pwd);
      curl_setopt($cInit, CURLOPT_HTTPHEADER, array('Accept: application/vnd.github.v3.text-match+json')); // ADD THE HIGHLIGHTED CODE SECTION
  
      // MAKE CURL OUTPUT READABLE
      $output = curl_exec($cInit);
      $items = json_decode($output, true); 
      curl_close($cInit); // CLOSE OUR API CONNECTION
  </code></pre>
  
  <p>Now, i've added in <code>curl_setopt($cInit, CURLOPT_HEADER, true);</code></p>
  
  <p>And now, for whatever reason - when i do <code>var_dump($items)</code> which worked before i added <code>CURLOPT_HEADER</code> to my code - instead returns a <code>NULL</code>. Which in turn breaks the entire project.</p>
  
  <p>Doing some debugging i found that <code>var_dump($output)</code> is still outputting data, and as expected has the header included. However, the Link <code>Header</code> looks like this:</p>
  
  <p><code>Link: ; rel="next", ; rel="last"</code> When it shouldnt. To my knowledge, it looks like the link header has actually broken my code.</p>
  
  <p>I've tried various things like trying to <code>urlencode</code> <code>$output</code> before i decode it, but to no avail. So, how do i fix this?</p>