['jpg', 'png', 'jpeg'], TemFile::TYPE_VIDEO => ['mp4'], TemFile::TYPE_EXCEL => [], TemFile::TYPE_WORD => ['docx'], TemFile::TYPE_TXT => ['txt'], ]; /** * @param $array * @param $value * @param int $key * @return int * 查看$extension数组中是否存在文件类型,不存在则返回-1 */ public function searchType($array,$value, $key=-1){ foreach($array as $k=>$row){ if(!is_array($row)){ if($row == $value){ if($key != -1) { return $key; }else{ return -1; } } }else{ $r = self::searchType($row,$value, $k); if($r != -1){ return $r; } } } return -1; } }