/** * Parsed version of $_SERVER['HTTP_ACCEPT'] * @return array array( 'mime_type' => array( 'qualifier' => <value>, ...), ... ) */ public static function http_accept() { if (self::$HTTP_ACCEPT === null) { self::$HTTP_ACCEPT = array(); // Initialize self::$HTTP_ACCEPT if (!empty($_SERVER['HTTP_ACCEPT'])) { $mime_types = explode(',', $_SERVER['HTTP_ACCEPT']); foreach ($mime_types as $value) { $value = split(';', $value); $mt = trim(array_shift($value)); self::$HTTP_ACCEPT[$mt]['q'] = 1.0; foreach ($value as $v) { if (preg_match('/^\\s*([^\\s=]+)\\s*=\\s*([^;]+?)\\s*$/', $v, $matches)) { self::$HTTP_ACCEPT[$mt][$matches[1]] = is_numeric($matches[2]) ? (double) $matches[2] : $matches[2]; } } } } } return self::$HTTP_ACCEPT; }