PHP检查字符串是否在数组中
in_array — 该函数检查某个字符串是否存在于数组中
bool in_array ( mixed
$needle
, array $haystack
[, bool $strict
= FALSE
] )
Searches haystack
for needle
using loose comparison unless strict
is set.
<?php $ext = "PPT"; $ext = strtolower($ext); $file_ext = array("doc", "ppt", "xls", "docx","xlsx","pptx","txt"); if (in_array($ext, $file_ext)) { echo "文档类型"; }else{ echo "其他类型"; } ?>