选择语言 :

 Core_File::exts_by_mime

Lookup file extensions by MIME type

array Core_File::exts_by_mime( string $type )

参数列表

参数 类型 描述 默认值
$type string File MIME type
返回值
  • array File extensions matching MIME type
File: ./core/classes/file.class.php
public static function exts_by_mime($type)
{
	static $types = array();

	// Fill the static array
	if (empty($types))
	{
        $mimes = Core::config('mimes');
		foreach ($mimes as $ext => $ms)
		{
			foreach ($ms as $mime)
			{
				if ($mime == 'application/octet-stream')
				{
					// octet-stream is a generic binary
					continue;
				}

				if (!isset($types[$mime]))
				{
					$types[$mime] = array( (string)$ext );
				}
				elseif (!in_array($ext, $types[$mime]))
				{
					$types[$mime][] = (string)$ext;
				}
			}
		}
	}

	return isset($types[$type])?$types[$type]:false;
}