Получил http заголовки, реализовываю чтобы они были в массиве
в таком виде:
CODE ( php):
скопировать код в буфер обмена
( [http_code] => HTTP/1.1 200 OK [Date] => Tue , 24 May 2016 14:03 :19 GMT [Server] => Apache [Last-Modified] => Mon, 12 Oct 2015 18:15:13 GMT [ETag] => "5af3800-521ec4f85b228" [Accept-Ranges] => bytes [Content-Length] => 95369216 [Content-Type] => application/octet-stream )
вот эта функция справляется:
PHP:
скопировать код в буфер обмена
// Split the string on every "double" new line. $arrRequests = explode("\r\n\r\n", $HeaderResult); /* Loop of response headers. The "count() -1" is to avoid an empty row for the extra line break before the body of the response.*/ for ($index = 0; $index < count($arrRequests) -1; $index++) { foreach (explode("\r\n", $arrRequests[$index]) as $i => $line) { if ($i === 0) { $headers[$index]['http_code'] = $line; } else { $headers[$index][$key] = $value; } } }
НО если приходят заголовок в виде:
то функция не правильно отображает
как подкорректировать?(Отредактировано автором: 24 Мая, 2016 - 17:16:14)
|