public static function get_file_type_from_mime($mime) {
		$validtypes = ['application', 'audio', 'image', 'message', 'multipart', 'text', 'video'];

		if (mb_stripos($mime, '/') === false) {
			// Malformed mime type.
			return false;
		}

		$iparts = explode('/', $mime);
		if (count($iparts) !== 2) {
			// Malformed mime type.
			return false;
		}

		return (in_array($iparts[0], $validtypes, true)) ? $iparts[0] : false;
	}
public static function get_file_type_from_mime($mime) {
		$validtypes = ['application', 'audio', 'image', 'message', 'multipart', 'text', 'video'];

		if (mb_stripos($mime, '/') === false) {
			// Malformed mime type.
			return false;
		}

		$iparts = explode('/', $mime);
		if (count($iparts) !== 2) {
			// Malformed mime type.
			return false;
		}

		return (in_array($iparts[0], $validtypes, true)) ? $iparts[0] : false;
	}
public static function get_file_type_from_mime ( $ mime ) { $ validtypes = [ 'application' , 'audio' , 'image' , 'message' , 'multipart' , 'text' , 'video' ] ; if ( mb_stripos ( $ mime , '/' ) === false ) { // Malformed mime type. return false ; } $ iparts = explode ( '/' , $ mime ) ; if ( count ( $ iparts ) !== 2 ) { // Malformed mime type. return false ; } return ( in_array ( $ iparts [ 0 ] , $ validtypes , true ) ) ? $ iparts [ 0 ] : false ; }
Get the general file type from a mime type.

This returns the beginning part (before the slash) of a mime type, giving a more general category of the file.

@param string $mime The mime type.
@return string The general file type.
Get the general file type from a mime type .