We often have the need to find all of the subdirectories of a particular directory. The code below demonstrates how to list the subdirectories of the current directory.
<?php
echo "<!DOCTYPE html>";
echo "<html>";
echo "<head>";
echo "</head>";
echo "<body>";
echo "<ul>";
$sDirectories = glob('*' , GLOB_ONLYDIR | GLOB_NOSORT);
foreach($sDirectories as $sCurrDir) {
$sDirPath = dirname(__FILE__)."/".$sCurrDir;
$qDirPathInfo = PathInfo($sDirPath);
// Make the first letter uppercase, if it is not already.
echo "<li>".ucfirst($qDirPathInfo['basename'])."</li>";
}
echo "</ul>";
echo "</body>";
echo "</html>";
?>
© 20072024 XoaX.net LLC. All rights reserved.