<?php
$types = [
'image/jpeg' => [
'jpg',
'jpeg',
'jpe'
],
'image/gif' => 'gif'
];
function getExtensionByMimeType(string $type): ?string
{
global $types;
if (!isset($types[$type])) {
return null;
}
if (is_array($types[$type])) {
return $types[$type][0];
}
return $types[$type];
}
var_dump(getExtensionByMimeType('image/gif')); // gif
$types
можно использовать этот список