Home  >  Article  >  Backend Development  >  Tutorial on how to traverse file directories in PHP

Tutorial on how to traverse file directories in PHP

黄舟
黄舟Original
2017-08-14 16:15:512154browse

In our daily development work, we often encounter the situation of traversing file directories. I believe everyone knows that there are many ways to traverse file directories. PHP itself also provides many useful functions. If there are many directories, everyone will use them. Queue mode, but what we will introduce to you today is the use of PHP classes to traverse file directories!

Step one:

Download the phpphp class we need to use this time to traverse the file directory: http://www.php.cn/xiazai/leiku/823

Second step:

Extract the downloaded files locally, and then instantiate the class:

1. Get the directory list:

<?php
$Dir_dir  = &#39;./example&#39;;

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

print_r($getDir);
?>

Result :

Tutorial on how to traverse file directories in PHP

2. Get the file list

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

$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);
?>

The result shows:

Tutorial on how to traverse file directories in PHP

##3 .Get directory/file list


<?php
$Dir_dir  = &#39;./example&#39;;

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

print_r($getDirFile);
?>

The result shows:

Tutorial on how to traverse file directories in PHP

The above is the detailed content of Tutorial on how to traverse file directories in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn