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.
Usage effect:
php file finder source code:
Copy code The code is as follows:
php version file search (file search) /*
* Note: Case sensitive
* by: http://www.jb51.net
*/
if(!empty($_POST['path'])&&!empty($_POST['key'])){
echo "Search for ".$_POST['key']." in the path ".$_POST['path']."/ and the result is:
";
$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/$item n";
$GLOBALS['r_file_num']++;
}
}
}
}
closedir( $handle );
$GLOBALS['dir_num']++;
if(strstr($dirName,$GLOBALS['findFile'])){
$loop = explode($GLOBALS['findFile'],$dirName);
$countArr = count($loop)-1;
if(empty($loop[$countArr])){
echo "
< ;b> $dirName n";
$GLOBALS['r_dir_num']++;
}
}
}else {
die("There is no such path! ");
}
}
delDirAndFile($_POST['path']);
echo "
This time a total of ".$file_num." files and folders ".$dir_num." were found< br/>";
echo "
A total of ".$r_file_num." files and folders ".$r_dir_num." matching the results
";
}
?>
http://www.bkjia.com/PHPjc/768135.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/768135.htmlTechArticleFor local, we can use the search that comes with windows to search, but for online, such as searching for ftp For files in the space, this program is very useful. Usage effect: php text...