note 117068 added to function.mime-content-type
| From: | alex at webedge dot ca | Date: | Fri, 10 Apr 2015 00:42:58 +0000 |
| Subject: | note 117068 added to function.mime-content-type | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202222@lists.php.net to get a copy of this message | ||
// Here is a working version of a function that fetches the meme types from apache's built in
mime list and creates an array of which the keys are the file extensions:
function generateUpToDateMimeArray($url){
$return = array();
$mimes = file_get_contents('http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types');
// make sure that allow_url_fopen is enabled!
preg_match_all('#^([^\s]{2,}?)\s+(.+?)$#ism', $mimes, $matches, PREG_SET_ORDER);
foreach ($matches as $match){
$exts = split(" ", $match[2]);
foreach ($exts as $ext){
$return[$ext]=$match[1];
}
}
return $return;
}
// usage:
$typeMime = generateUpToDateMimeArray();
echo $typeMime['gif'];
----
Server IP: 72.52.91.14
Probable Submitter: 68.71.38.154
----
Manual Page -- http://php.net/manual/en/function.mime-content-type.php
Edit -- https://master.php.net/note/edit/117068
Del: integrated -- https://master.php.net/note/delete/117068/integrated
Del: useless -- https://master.php.net/note/delete/117068/useless
Del: bad code -- https://master.php.net/note/delete/117068/bad+code
Del: spam -- https://master.php.net/note/delete/117068/spam
Del: non-english -- https://master.php.net/note/delete/117068/non-english
Del: in docs -- https://master.php.net/note/delete/117068/in+docs
Del: other reasons-- https://master.php.net/note/delete/117068
Reject -- https://master.php.net/note/reject/117068
Search -- https://master.php.net/manage/user-notes.php