I'm trying to get a list with folders and subfolders, I have the following, which allows me to get folders and auxiliary folders, but I needed to sort it, like the ones below, which I tried, but I donβt know how I would get around .
Root/ Root/Images Root/Images/UserImages Root/Text/ Root/Text/User1/ Root/Text/User1/Folder2
but on monent its display like this
Root/css/ tree/css/ js/ images/
PHP CODE:
function ListFolder($path) { $dir_handle = @opendir($path) or die("Unable to open $path"); //Leave only the lastest folder name $dirname = end(explode("/", $path)); //display the target folder. echo ("$dirname/"); while (false !== ($file = readdir($dir_handle))) { if($file!="." && $file!="..") { if (is_dir($path."/".$file)) { //Display a list of sub folders. ListFolder($path."/".$file); echo "<br>"; } } } //closing the directory closedir($dir_handle); } ListFolder("../");
thanks
Rickstar
source share