How to make a pregmatch match both 'location: ' and 'Location: '?
'location: '
'Location: '
preg_match('#Location: (.*)#', $curl, $result)
Just make the regex case insensitive:
preg_match('#Location: (.*)#i', $curl, $result) // here __^