如何根据部分文件名检查文件是否存在? [英] How can i check if file exists based on a partial file name?
本文介绍了如何根据部分文件名检查文件是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试检查我的文件夹中是否存在文件,但是我只能使用部分文件名进行检查,有没有办法检查它?
Im trying to check if a file exists in my folder but i only have a partial filename to check it against, Is there a way to check it?
例如,我有以下内容:
God_of_War
文件名实际上称为:
God_of_War_PSP(USA).rar
是否存在某种类似于file_exists的功能?或者我可以以某种方式使用str_pos吗?
Is there some kind of LIKE for file_exists function ? or can i use str_pos somehow ?
谢谢
推荐答案
您可以使用类似于以下内容的东西:
You could use something similar to the following:
$fileSearch = "God_of_War";
$files = glob("/path/*" . $fileSearch . "*");
if(count($files) > 0) echo "File Exists!";
这篇关于如何根据部分文件名检查文件是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文