When I fetch all headers via
$response = curl_exec($curl);
$header_size = curl_getinfo($curl,CURLINFO_HEADER_SIZE);
$result = substr($response, 0, $header_size);
I get an output like
HTTP/1.1 302 Found
Server: nginx
Date: Mon, 06 Jul 2015 14:58:06 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 0
Connection: keep-alive
Status: 302 Found
Location: https://data.myserver.com
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: 9e2a562ec3ba73a72702e84fa7177c56
X-UA-Compatible: IE=Edge,chrome=1
Cache-Control: no-cache
X-Runtime: 0.046013
X-Rack-Cache: miss
Accept-Ranges: bytes
X-Varnish: 945594494
Age: 0
Via: 1.1 varnish
Strict-Transport-Security: max-age=31536000
I only want the 'Location:' value, in Java it was easy however in PHP, I could not find a simple elegant solution without using regex.