PHP code example of bitworking / mimeparse

1. Go to this page and download the library: Download bitworking/mimeparse library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bitworking / mimeparse example snippets



$supportedTypes = array('application/xbel+xml', 'text/xml');
$httpAcceptHeader = 'text/*;q=0.5,*/*; q=0.1';

$mimeType = \Bitworking\Mimeparse::bestMatch($supportedTypes, $httpAcceptHeader);

echo $mimeType; // Should echo "text/xml"


$httpAcceptHeader = 'text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, *\/*;q=0.5';

$quality = \Bitworking\Mimeparse::quality('text/html', $httpAcceptHeader);

echo $quality; // Should echo 0.7