Hello? I have a working php script its only php based.. it works like this --- index.php ------ /Layout1 ------ /Layout1/Cool_Layout1 ------ /Layout1/Cool_Layout2 ------ /Layout1/Cool_Layout3 ------ /Layout1/Cool_Layout4 ------ /Layout2 ------ /Layout2/Cool_Layout1 ------ /Layout2/Cool_Layout2 ------ /Layout2/Cool_Layout3 PHP: Is it possible to change the index.php to output how many folders a subfolder has? So to preview it in the index.php Layout1 (4) Layout2 (3) and so on and so on.. ? I have managed to count images in 1 subfolder, but i cannot manage to count the folders, please help? Thx!
http://www.php.net/manual/en/function.is-dir.php Use is_dir() is check and count the files of the root
I know how to count the files in a folder, but i neeed to count the folders in a subfolder you se!? -- /index.php -- /Layouts/ -- /Layouts/1/index.php -- /Layouts/2/ -- /Layouts/3/ -- /Layouts/4/ -- /Layouts/5/ PHP: Each subfolder, contains: 2 images 1 css file Any other ways of doing it? Thx!
I think he's saying use is_dir() to do it recursively.. each file in a directory, pass it through is_dir(), if it returns true.. take that current path and make it go through your file-counting thing again to grab the sub-folders files.
I wrote a little chunk of example cold of how to go in recursively.. I haven't tested it but it should work (I hope?). The only problem I see is it'll go into a new folder as it sees it instead of listing current directories contents first, then go into subfolder and list those, etc. Could fix by some tweaking. <?php list_dir("./"); function list_dir($dir, $recur = false) { if (is_dir($dir)) { $dh = opendir($dir); while (($files = readdir($dh)) !== false) { if ($files == ".." || $files == ".") continue; if ($recur) { echo "SubFolder: $files <br />"; } else { echo "Main Folder: $files <br />"; } if (is_dir($dir . $files)) { list_dir($dir . $files . "/", true); } } } } ?> PHP: