一起源码网

标题: php如何遍历文件目录的方法教程 [打印本页]

作者: 云文章    时间: 2020-4-12 02:30
标题: php如何遍历文件目录的方法教程
在我们日常开发工作中,经常会遇到遍历文件目录的情况,相信大家也知道对于遍历文件目录的有很多种,PHP本身也提供了很多有用的函数,如果目录很多,大家都会用队列方式,但是我们今天给大家介绍的是php遍历文件目录的类使用!

第一步:

下载我们本次需要使用的phpphp遍历文件目录的类:

第二步:

把下载的文件解压都本地,然后实例化类:

1.获取目录列表:

<?php
$Dir_dir  = './example';

$getDirFile = new getDirFile();
$getDir = $getDirFile->getDir( $Dir_dir );

print_r($getDir);
?>

结果:

2.获取文件列表

<?php
$File_one_dir = './example/example_one';
$File_two_dir = 'E:/Workspace/mycode/getDirFile/example/example_two';

$getDirFile = new getDirFile();
$getFile_one = $getDirFile->getFile( $File_one_dir );
$getFile_two = $getDirFile->getFile( $File_two_dir );

print_r($getFile_one);
print_r($getFile_two);
?>

结果显示:

3.获取目录/文件列表

<?php
$Dir_dir  = './example';

$getDirFile = new getDirFile();
$getDirFile  = $getDirFile->getDirFile( $Dir_dir );

print_r($getDirFile);
?>

结果显示:


作者: smellbee    时间: 2022-8-6 23:27
android10版本官方下载




欢迎光临 一起源码网 (https://www.171739.xyz/) Powered by Discuz! X3.3