$value) { if (strpos($key, 'HTTP_') === 0) { $key = strtolower(substr($key, 4)); $key = preg_replace_callback('/_\w/', 'header_callback', $key); $key = substr($key, 1); $key = str_replace('_', '-', $key); if ($key == 'Host') continue; $headers[] = "$key:$value"; } } $remoteIp = $_SERVER['REMOTE_ADDR']; $headers[] = "X-FORWARDED-FOR:$remoteIp"; $headers[] = "X-REAL-IP:$remoteIp"; return $headers; } function header_callback($str) { return strtoupper($str[0]); } function parseResponse($response) { $result = explode("\r\n\r\n", $response, 2); if (preg_match('/^HTTP\/1\.(0|1) \d{3}/', $result[1])) { $result = parseResponse($$result[1]); } return $result; } curl_close($ch); echo $resBody;