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: //m.sbmmt.com/xiazai/leiku/823
Second step:
Extract the downloaded files locally, and then instantiate the class:
1. Get the directory list:
<?php $Dir_dir = './example'; $getDirFile = new getDirFile(); $getDir = $getDirFile->getDir( $Dir_dir ); print_r($getDir); ?>
Result :
2. Get the file list
<?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); ?>
The result shows:
##3 .Get directory/file list<?php $Dir_dir = './example'; $getDirFile = new getDirFile(); $getDirFile = $getDirFile->getDirFile( $Dir_dir ); print_r($getDirFile); ?>
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!