Home >Backend Development >PHP Tutorial >How to display subdirectories under a specified directory in php, specify the directory in php_PHP tutorial
The example in this article describes how to display subdirectories under a specified directory in php. Share it with everyone for your reference. The specific implementation method is as follows:
<?php echo "<h2>subdirs in dir</h2><ul>"; $basedir = basename( __FILE__ ); $dirtoscan = ($basedir . '/somedir/'); $albumlisting = scandir($dirtoscan); foreach ($albumlisting as $item) { $dirinfo = pathinfo($item); print_r($dirinfo); if (is_dir("$item")) { echo "<li><a href='index.php?subdirs=$item'>$item</a></li>"; } } ?>
I hope this article will be helpful to everyone’s PHP programming design.