Home >Backend Development >PHP Tutorial >PHP lists file directory tree php php directory operation php mkdir multi-level directory
PHP is a way to list the file directory tree. It can also determine whether the file is a directory and clearly display the files in the directory. It can help us understand the directory situation well and quickly see the directory. How many directories are there in total and which ones are not directory files? This is a relatively practical little method that can be applied to In the php file management system, it helps us list the file directory tree, understand it at a glance, and improve its files. It is a good PHP file for managing directories. The source code is as follows:
<?php $str= "D:/xxcms/"; ListDir($str); functionListDir ($dirname) { $Ld= dir($dirname); echo"<ul>"; while(false !== ($entry= $Ld->read())) { $checkdir=$dirname."/".$entry; if(is_dir($checkdir)&&!preg_match("[^\.]",$entry)){ echo"<li><p>".$checkdir."当前<span style='color:#ff00a a'>是</span>目录</p></li>"; ListDir($checkdir); }else{ echo"<li><p>".$entry."当前不是目录</p></li>"; } } $Ld->close(); echo"</ul>"; } ?>
The above introduces PHP to list the file directory tree, including PHP and directory content. I hope it will be helpful to friends who are interested in PHP tutorials.