php中的Strpos函数和一个数组作为指针


Strpos function in php and an array as needle

我想在php中检查上传文件的mime类型,如果允许则返回true。

我有一个包含部分允许的mime类型的数组,像这样:

$allowedMimes = array('images','word','pdf');

images用于jpg/png/gif, word用于doc/docx, PDF用于PDF。

上传的docx文件的mime类型,例如:

application/vnd.openxmlformats-officedocument.wordprocessingml.document

现在我需要在数组中检查它。我想我应该使用strpos,但我不知道如何在数组中使用它。

你能帮我吗?
foreach( $allowedMimes as $mime ) {
   if( strpos( 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' , $mime ) ) {
    return true;
  }
}