Strpos function in php and an array as needle
문제
I want to check the mime-type of uploaded file in php and return true if it is allowed.
I have an array of some part of allowed mime-types like this:
$allowedMimes = array('images','word','pdf');
images is for jpg/png/gif and word is for doc/docx and pdf for pdf.
the mime-type of an uploaded docx file is for example:
application/vnd.openxmlformats-officedocument.wordprocessingml.document
now i need to check it in array.i think i should use strpos but i don't know how use it with an array.
would you help me?
해결책
foreach( $allowedMimes as $mime ) {
if( strpos( 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' , $mime ) ) {
return true;
}
}
제휴하지 않습니다 StackOverflow