note 107798 added to function.mime-content-type
| From: | JoshSean | Date: | Mon, 05 Mar 2012 19:04:37 +0000 |
| Subject: | note 107798 added to function.mime-content-type | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186504@lists.php.net to get a copy of this message | ||
Fast generation of uptodate mime types:
<?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[]=' \''.$out[1][$i].'\' =>
\''.$out[1][0].'\'';
return @sort($s)?'$mime_types = array(<br />'.implode($s,',<br
/>').'<br />);':false;
}
echo
generateUpToDateMimeArray(APACHE_MIME_TYPES_URL);
?>
Output:
$mime_types = array(
'123' => 'application/vnd.lotus-1-2-3',
'3dml' => 'text/vnd.in3d.3dml',
'3g2' => 'video/3gpp2',
'3gp' => 'video/3gpp',
'7z' => 'application/x-7z-compressed',
'aab' => 'application/x-authorware-bin',
'aac' => 'audio/x-aac',
'aam' => 'application/x-authorware-map',
'aas' => 'application/x-authorware-seg',
...
Enjoy.
----
Server IP: 69.147.83.197
Probable Submitter: 74.63.112.149
----
Manual Page -- http://www.php.net/manual/en/function.mime-content-type.php
Edit -- https://master.php.net/note/edit/107798
Del: integrated -- https://master.php.net/note/delete/107798/integrated
Del: useless -- https://master.php.net/note/delete/107798/useless
Del: bad code -- https://master.php.net/note/delete/107798/bad+code
Del: spam -- https://master.php.net/note/delete/107798/spam
Del: non-english -- https://master.php.net/note/delete/107798/non-english
Del: in docs -- https://master.php.net/note/delete/107798/in+docs
Del: other reasons-- https://master.php.net/note/delete/107798
Reject -- https://master.php.net/note/reject/107798
Search -- https://master.php.net/manage/user-notes.php