Skip to content

Instantly share code, notes, and snippets.

@rodrigocnascimento
Created September 14, 2014 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigocnascimento/dee476f5af863f0d4220 to your computer and use it in GitHub Desktop.
Save rodrigocnascimento/dee476f5af863f0d4220 to your computer and use it in GitHub Desktop.
mime_type_functions.php
<?php
define('APACHE_MIME_TYPES_URL','http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types');
function generateUpToDateMimeArray($url){
$s=array();
foreach(@explode("\n",@file_get_contents($url))as $x)
if(isset($x[0])&&$x[0]!=='#'&&preg_match_all('#([^\s]+)#',$x,$out)&&isset($out[1])&&($c=count($out[1]))>1)
for($i=1;$i<$c;$i++)
$s[]='&nbsp;&nbsp;&nbsp;\''.$out[1][$i].'\' => \''.$out[1][0].'\'';
return @sort($s)?'$mime_types = array(<br />'.implode($s,',<br />').'<br />);':false;
}
echo
generateUpToDateMimeArray(APACHE_MIME_TYPES_URL);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment