<?php
function my_scandir($dir)
{
$files = array();
if ( $handle = opendir($dir) ) {
while ( ($file = readdir($handle)) !== false ) {
if ( $file != ".." && $file != "." ) {
if ( is_dir($dir . "/" . $file) ) {
$files[$file] = my_scandir($dir . "/" . $file);
}else {
$files[] = $file;
}
}
}
closedir($handle);
return $files;
}
}
dump(my_scandir("D:\wwwroot"));
function dump($vars){
$content = "<div align=left><pre class="brush:php;toolbar:false;">\n" . htmlspecialchars(print_r($vars, true)) . "\n默认情况下,返回值是按照字母顺序升序排列的。如果使用了可选参数 sorting_order(设为 1),则按照字母顺序降序排列。
以上就介绍了(最明了)写一个函数,能够遍历一个文件夹下的所有文件和子文件夹。,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号