PHP Mime type checking alternative way of doing it?
<p>I noticed that get_mime() is now depreciated so what would be an alternative way of creating the following function? This function is used through a cms that I work with so need a reliable alternative.</p>

<pre><code> // Mime Type Checker
function get_mime($filename,$mode=0){

    // mode 0 = full check
    // mode 1 = extension check only

    $mime_types = array(

        'txt' =&gt; 'text/plain',
        'htm' =&gt; 'text/html',
        'html' =&gt; 'text/html',
        'php' =&gt; 'text/html',
        'css' =&gt; 'text/css',
        'js' =&gt; 'application/javascript',
        'json' =&gt; 'application/json',
        'xml' =&gt; 'application/xml',
        'swf' =&gt; 'application/x-shockwave-flash',
        'flv' =&gt; 'video/x-flv',

        // images
        'png' =&gt; 'image/png',
        'jpe' =&gt; 'image/jpeg',
        'jpeg' =&gt; 'image/jpeg',
        'jpg' =&gt; 'image/jpeg',
        'gif' =&gt; 'image/gif',
        'bmp' =&gt; 'image/bmp',
        'ico' =&gt; 'image/vnd.microsoft.icon',
        'tiff' =&gt; 'image/tiff',
        'tif' =&gt; 'image/tiff',
        'svg' =&gt; 'image/svg+xml',
        'svgz' =&gt; 'image/svg+xml',

        // archives
        'zip' =&gt; 'application/zip',
        'rar' =&gt; 'application/x-rar-compressed',
        'exe' =&gt; 'application/x-msdownload',
        'msi' =&gt; 'application/x-msdownload',
        'cab' =&gt; 'application/vnd.ms-cab-compressed',

        // audio/video
        'mp3' =&gt; 'audio/mpeg',
        'qt' =&gt; 'video/quicktime',
        'mov' =&gt; 'video/quicktime',

        // adobe
        'pdf' =&gt; 'application/pdf',
        'psd' =&gt; 'image/vnd.adobe.photoshop',
        'ai' =&gt; 'application/postscript',
        'eps' =&gt; 'application/postscript',
        'ps' =&gt; 'application/postscript',

        // ms office
        'doc' =&gt; 'application/msword',
        'rtf' =&gt; 'application/rtf',
        'xls' =&gt; 'application/vnd.ms-excel',
        'ppt' =&gt; 'application/vnd.ms-powerpoint',
        'docx' =&gt; 'application/msword',
        'xlsx' =&gt; 'application/vnd.ms-excel',
        'pptx' =&gt; 'application/vnd.ms-powerpoint',


        // open office
        'odt' =&gt; 'application/vnd.oasis.opendocument.text',
        'ods' =&gt; 'application/vnd.oasis.opendocument.spreadsheet',
        );

    $ext = strtolower(array_pop(explode('.',$filename)));



if(function_exists('mime_content_type')&amp;&amp;$mode==0){
        $mimetype = mime_content_type($filename);
        return $mimetype;
        }

    if(function_exists('finfo_open')&amp;&amp;$mode==0){
        $finfo = finfo_open(FILEINFO_MIME);
        $mimetype = finfo_file($finfo, $filename);
        finfo_close($finfo);
        return $mimetype;
        }
    elseif(array_key_exists($ext, $mime_types)){
        return $mime_types[$ext];
        }
    else {
        return 'application/octet-stream';
        }
     }
</code></pre>
