Home > Backend Development > PHP Tutorial > Recursively traverse all file instance codes directly

Recursively traverse all file instance codes directly

零下一度
Release: 2023-03-12 08:24:02
Original
1039 people have browsed it
<?php  
  
//直接遍历所有文件.递归  function trees($dirname){  $dirOb = dir($dirname);  
     echo "<ul>\n";  while($file = $dirOb->read()){  if($file == "." || $file == ".."){  
              
        }else{  if(is_dir("$dirname/$file")){  echo "<li><font color=\"#ff00cc\"><b>$file</b></font></li>\n";  
                trees("$dirname/$file");  
            }else{  
                 echo "<li>$file</li>\n";  
            }  
        }  echo "<br/>";  
    }  echo "</ul>\n";  
}  
trees("../tp5");
Copy after login

The above is the detailed content of Recursively traverse all file instance codes directly. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template