1 file.module file_match_mimetypes($needle, $haystack)

Checks if pattern(s) match mimetype(s).

File

core/modules/file/file.module, line 1977
Defines a "managed_file" Form API field and a "file" field for Field module.

Code

function file_match_mimetypes($needle, $haystack) {
  $needle = is_array($needle) ? $needle : array($needle);
  $haystack = is_array($haystack) ? $haystack : array($haystack);

  foreach ($haystack as $mimetype) {
    foreach ($needle as $search) {
      if (file_fnmatch($search, $mimetype) || file_fnmatch($mimetype, $search)) {
        return TRUE;
      }
    }
  }

  return FALSE;
}