在文件夹/目录(PHP)中搜索特定的文件扩展名 [英] Searching for specific file extensions in a folder/directory (PHP)

查看:210
本文介绍了在文件夹/目录(PHP)中搜索特定的文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PHP设计一个程序,该程序将允许我在包含多个文件夹的已知目录中查找具有特定文件扩展名的文件(例如.jpg,.shp等)。
非常感谢我需要使用哪种方法的示例代码,文档或信息。

I'm trying to design a program in PHP that would allow me to find files with specific file extensions (example .jpg, .shp etc) in a known directory which consists of multiple folders. Sample code, documentation or information about what methods I will be required to use will be much appreciated.

推荐答案

< a href = http://php.net/manual/zh/function.glob.php rel = noreferrer> glob 很简单:

glob is pretty easy:

<?php
foreach (glob("*.txt") as $filename) {
    echo "$filename size " . filesize($filename) . "\n";
}
?>

readdir 页面

这篇关于在文件夹/目录(PHP)中搜索特定的文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆