How to implement file search in PHP? PHP file search program, after entering a path, it will traverse all the files and folders in the directory. Through recursion, you can find each file under the folder, and then match the file name with the entered keywords to find the file you want. Friends in need can refer to the file. I hope to be helpful.
For local, we can use the search that comes with Windows to search, but for online, such as searching for files in ftp space, this program is very useful.
php file finder source code:
"; $file_num = $dir_num = 0; $r_file_num = $r_dir_num= 0; $findFile = $_POST['key']; function delDirAndFile( $dirName ){ if ( $handle = @opendir( "$dirName" ) ) { while ( false !== ( $item = readdir( $handle ) ) ) { if ( $item != "." && $item != ".." ) { if ( is_dir( "$dirName/$item" ) ) { delDirAndFile( "$dirName/$item" ); } else { $GLOBALS['file_num']++; if(strstr($item,$GLOBALS['findFile'])){ echo " $dirName/$itemphp版文件查找(file search)
Related recommendations:
Detailed explanation How to implement a simple search box automatic prompt function in PHP
Detailed explanation of how to implement Sudoku solving in PHP
Detailed explanation of how PHP implements importing csv files into the database
The above is the detailed content of Detailed explanation of how to implement file search in PHP. For more information, please follow other related articles on the PHP Chinese website!