public function Request::splitHttpAcceptHeader

Splits an Accept-* HTTP header.

Parameters

string $header Header to split:

Return value

array Array indexed by the values of the Accept-* header in preferred order

3 calls to Request::splitHttpAcceptHeader()
Request::getAcceptableContentTypes in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php
Gets a list of content types acceptable by the client browser
Request::getCharsets in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php
Gets a list of charsets acceptable by the client browser.
Request::getLanguages in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php
Gets a list of languages acceptable by the client browser.

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php, line 1270

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

public function splitHttpAcceptHeader($header) {
  if (!$header) {
    return array();
  }
  $values = array();
  foreach (array_filter(explode(',', $header)) as $value) {

    // Cut off any q-value that might come after a semi-colon
    if (preg_match('/;\\s*(q=.*$)/', $value, $match)) {
      $q = (double) substr(trim($match[1]), 2);
      $value = trim(substr($value, 0, -strlen($match[0])));
    }
    else {
      $q = 1;
    }
    if (0 < $q) {
      $values[trim($value)] = $q;
    }
  }
  arsort($values);
  reset($values);
  return $values;
}