我有一个名为 myfiles
( c/myfiles
( 的文件夹,我想验证此文件夹中是否包含以名称 filesearch_
开头的文件。
在 C: 目录中,我有:
files.txt
filesearch_232142.xls //TRUE in this case
filesearch_12.pdf //TRUE in this case
fdsf.php
搜索filesearch_
结果应该是 true
.如果没有,则应false
.我研究过glob
,但不明白如何放置glob
模式函数。
我只会使用 PHP ReadDir 来查看文件是否存在:
<?php
$dir = "c:/myfiles";
// Open a directory, and read its contents
if (is_dir($dir)){
if ($dh = opendir($dir)){
while (($file = readdir($dh)) !== false){
if (substr($file,0,11) == "filesearch_") {
// file exists
}
closedir($dh);
}
}
?>