note 117528 deleted from reserved.variables.server by cmb

From: Date: Sun, 28 Jul 2019 08:05:10 +0000
Subject: note 117528 deleted from reserved.variables.server by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211716@lists.php.net to get a copy of this message
Note Submitter: doublecompile at gmail dot com ---- I've used the SplPriorityQueue to determine an HTTP client's preferred MIME types that are in $_SERVER['HTTP_ACCEPT']. <?php $queue = new \SplPriorityQueue(); foreach (preg_split('#,\s*#', $_SERVER['HTTP_ACCEPT']) as $accept) { $split = preg_split('#;\s*q=#', $accept, 2); $queue->insert($split[0], isset($split[1]) ? (float)$split[1] : 1.0); } foreach ($queue as $mime) { echo $mime, PHP_EOL; } ?> My browser sends: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 And this script outputs: text/html application/xhtml+xml application/xml */* A better example: Accept: text/html, application/xml,text/css;q=0.4,text/plain; q=0.9, application/json;q=0.8 And this script outputs: text/html application/xml text/plain application/json text/css

« previous php.notes (#211716) next »