Jump to content

Archived

This topic is now archived and is closed to further replies.

madspof

php subfolder listing

Recommended Posts

it does'nt have to  be nested what ever is easier for you tho i would prefer nested

Share this post


Link to post
Share on other sites
it does'nt have to  be nested what ever is easier for you tho i would prefer nested

Share this post


Link to post
Share on other sites
This will list folders and their nested subfolders
[code]<?php


function listSubFolders ($dir, $level=0) {
    if ($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir("$dir/$file")) {
                    $indent = str_repeat('---', $level);
                    echo "$indent $file<br>";
                    listSubFolders("$dir/$file", $level+1);  // list subfolders of this folder
                }
            }
        }
        closedir($handle);
    }
}

$dir = 'c:/inetpub/wwwroot';      // <-- specify folder
listSubFolders($dir);
?>[/code]

Share this post


Link to post
Share on other sites
this is very good but i cannot see a way of the script being able to make a link to the folders

Share this post


Link to post
Share on other sites
Add [code]<a href='.....'>...........</a>[/code] tags.

Thought I'd leave you something to do.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.