]+>|[^=]+/', $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; } /** * Converts an array of header values that may contain comma separated * headers into an array of headers with no comma separated values. * * @param string|array $header Header to normalize. * * @return array Returns the normalized header field values. */ public static function normalize($header) { if (!\is_array($header)) { return \array_map('trim', \explode(',', $header)); } $result = []; foreach ($header as $value) { foreach ((array) $value as $v) { if (\strpos($v, ',') === \false) { $result[] = $v; continue; } foreach (\preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) { $result[] = \trim($vv); } } } return $result; } }