假设我在一个文件夹中有所有这些文件:
something(34324).php
something(34).php
something(3433454546).php
something(65565).php
something(9887).php
something(4585).php // ect ect
现在,我需要以某种方式检查是否存在任何something.php
文件(忽略编号)。
因此,如果文件夹中存在something(a_number).php
,则返回true。。。
有什么想法可以让我做这样的事情吗?
您可以使用glob()
,它返回一个匹配通配符模式的目录内容数组。
$somethings = glob('something*.php');
if (!empty($somethings)) {
// something exists
}