YoastSEO_Vendor\GuzzleHttp\Psr7
parse_header() Yoast 1.0
Parse an array of header values containing ";" separated data into an array of associative arrays representing the header key value pair data of the header. When a parameter does not contain a value, but just contains a key, this function will inject a key with a '' string value.
Хуков нет.
Возвращает
Массив. Returns the parsed header values.
Использование
parse_header( $header );
- $header(строка/массив) (обязательный)
- Header to parse into components.
Код parse_header() parse header Yoast 15.7
function parse_header($header)
{
static $trimmed = "\"' \n\t\r";
$params = $matches = [];
foreach (normalize_header($header) as $val) {
$part = [];
foreach (\preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
if (\preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
$m = $matches[0];
if (isset($m[1])) {
$part[\trim($m[0], $trimmed)] = \trim($m[1], $trimmed);
} else {
$part[] = \trim($m[0], $trimmed);
}
}
}
if ($part) {
$params[] = $part;
}
}
return $params;
}