php source code to traverse all the files in the directory:
<!--?php //遍历目录下的所有的文件 -- 递归调用 // <a rel="nofollow" href=" target="_blank"-->http://www.manongjc.com/article/1495.html function get_all_file1($path){ if($path != '.' && $path != '..' && is_dir($path)){ //判断是否是目录,并且不是. 和.. $files = []; //存储文件信息 if($handle = opendir($path)){ //打开 while($file = readdir($handle)){ //读取 if($file != '.' && $file != '..'){ $file_name = ($path . DIRECTORY_SEPARATOR . $file); if(is_dir($file_name)){ //判断是否是目录 $files[$file] = get_all_file1($file_name); //递归 }else{ $files[] = $file_name; } } } } } closedir($handle); //关闭句柄 return $files; } // <a rel="nofollow" href="http://www.manongjc.com/article/1481.html" target="_blank">http://www.manongjc.com/article/1481.html</a> var_dump(get_all_file1('F:\Apache\www\temp\php_demo')); ?>
The above is the content of the php source code to traverse all the files in the directory. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!