php获取文件夹下所有文件
作者:野牛程序员:2023-11-13 17:02:17php阅读 2930
使用PHP获取文件夹下所有文件可以使用scandir
函数或者glob
函数。以下是两种方法的示例代码:
使用scandir
函数:
$folderPath = '/path/to/your/folder'; // 获取文件夹下的所有文件和目录 $files = scandir($folderPath); // 遍历输出文件和目录 foreach ($files as $file) { echo $file . "\\n"; }
使用glob
函数:
$folderPath = '/path/to/your/folder'; // 获取文件夹下的所有文件 $files = glob($folderPath . '/*'); // 遍历输出文件 foreach ($files as $file) { echo $file . "\\n"; }
这两种方法都可以用于获取文件夹下的所有文件。
野牛程序员教少儿编程与信息学奥赛-微信|电话:15892516892

- 上一篇:【内部资料】arduino循迹避障小车程序
- 下一篇:php循环读取文件夹里的文件