I've been looking around in the PHP documentation for some time, but I found no way to convert a MIME type extension to a file type extension.
image_type_to_extension
Seems to work if the file is an image. In my particular case, the mime types are not for images, they are for font types: 'otf, ttf'.
You could use something like:
function getExtension ($mime_type){
$extensions = array('image/jpeg' => 'jpeg',
'text/xml' => 'xml'
);
// Add as many other Mime Types / File Extensions as you like
return $extensions[$mime_type];
}
Note: not every MIME type has a fixed file extension. Also, MIME types like application/octet-stream
can refer to multiple file extensions.