code: private function getHeaderArrayFromCurlResponse($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;
      }
docs: See https://stackoverflow.com/questions/10589889/returning-header-as-array-using-curl