0) if (substr($mt_buf,0,1) != "#") { /* make temp array of the mime.types line we just read */ $mt_tmp=preg_split("/[\s]+/", $mt_buf, -1, PREG_SPLIT_NO_EMPTY); $mt_num=count($mt_tmp); /* if $mt_num = 1 then we got no file extensions for the type */ if ($mt_num > 1) { for ($i=1;$i<$mt_num;$i++) { /* if we find a comment mid-line, stop processing */ if (strstr($mt_tmp[$i],"#")) { break; /* otherwise stick the type in an array keyed by extension */ } else { $mime_types[$mt_tmp[$i]]=$mt_tmp[0]; } } /* zero the temporary array */ unset($mt_tmp); } } } /* close the mime.types file we were reading */ fclose($mt_fd); } else { echo "ERROR: unreadable file " . $mt_f . "\n"; } /* eg, mime_lookup("doc") returns "application/ms-word" */ function mime_lookup($ext) { global $mime_types; return $mime_types[$ext]; } ?>