Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HeaderUtils.php

function HeaderUtils::groupParts

1 call to HeaderUtils::groupParts()
HeaderUtils::split in vendor/symfony/http-foundation/HeaderUtils.php
Splits an HTTP header by one or more separators.

File

vendor/symfony/http-foundation/HeaderUtils.php, line 256

Class

HeaderUtils
HTTP header utility functions.

Namespace

Symfony\Component\HttpFoundation

Code

private static function groupParts(array $matches, string $separators, bool $first = true) : array {
    $separator = $separators[0];
    $separators = substr($separators, 1) ?: '';
    $i = 0;
    if ('' === $separators && !$first) {
        $parts = [
            '',
        ];
        foreach ($matches as $match) {
            if (!$i && isset($match['separator'])) {
                $i = 1;
                $parts[1] = '';
            }
            else {
                $parts[$i] .= self::unquote($match[0]);
            }
        }
        return $parts;
    }
    $parts = [];
    $partMatches = [];
    foreach ($matches as $match) {
        if (($match['separator'] ?? null) === $separator) {
            ++$i;
        }
        else {
            $partMatches[$i][] = $match;
        }
    }
    foreach ($partMatches as $matches) {
        if ('' === $separators && '' !== ($unquoted = self::unquote($matches[0][0]))) {
            $parts[] = $unquoted;
        }
        elseif ($groupedParts = self::groupParts($matches, $separators, false)) {
            $parts[] = $groupedParts;
        }
    }
    return $parts;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal