Php glob函数。查找扩展名为“”的所有文件
是否查找扩展名为.name的所有文件Php glob函数。查找扩展名为“”的所有文件,php,Php,是否查找扩展名为.name的所有文件 $file=null; $file=glob('*/*/media/name.*'); rsort($文件); 回声';打印(文件);回声'; echo$文件[0]。; echo$file\u ext=pathinfo($file[0],pathinfo\u扩展名); 您需要使用 $name=“你好”; $files=glob(“/path/to/files/$name.*”);//将查找扩展名为hello.com的所有文件 如果(计数($files)>0)
$file=null;
$file=glob('*/*/media/name.*');
rsort($文件);
回声';打印(文件);回声';
echo$文件[0]。
;
echo$file\u ext=pathinfo($file[0],pathinfo\u扩展名);
您需要使用
$name=“你好”;
$files=glob(“/path/to/files/$name.*”);//将查找扩展名为hello.com的所有文件
如果(计数($files)>0){
foreach($files作为$file)
{
$info=pathinfo($file);
echo“找到文件:扩展名”。$info[“扩展名”]。“
”;
}
}否则{
echo“不存在名为$name的文件名。”
}
是的,就是这样possible@Cem菲拉特,你能接受我的回答吗?
$name= "hello";
$files = glob("/path/to/files/$name.*"); // Will find all file with hello.extension
if (count($files) > 0){
foreach ($files as $file)
{
$info = pathinfo($file);
echo "File found: extension ".$info["extension"]."<br>";
}
}else{
echo "No file name exists called $name."
}