hellonoko Posted October 10, 2008 Share Posted October 10, 2008 I have a directory /subdomains/ And inside of that directory is a user folder /mike/ /bob/ /tim/ etc. I have written a simple scrip to count the files inside the user folder: <?php session_start(); echo "<title>count</title>"; $dir = "subdomains/" . $_SESSION['login'] . "/filez/"; $count = count(glob($dir . "*.mp3")); echo $_SESSION['login']; echo '<br>'; echo $count; ?> What I am now trying to do is put this script inside a script that can go through each directory and count the number of files and then sort them by most to least. So I can return: Mike 10 Bob 8 Jim 5 and so on. I think I need to place it all in a loop that places each directory count into a array as it goes through the directories in /subdomains/ but I am not sure how to work with directories in that way. Thanks in advance, ian Quote Link to comment Share on other sites More sharing options...
ghostdog74 Posted October 10, 2008 Share Posted October 10, 2008 here's a simple example you can explore <?php $path = realpath('/directory'); $iterator = new RecursiveDirectoryIterator($path); foreach (new RecursiveIteratorIterator($iterator, 2) as $path){ if($path->isDir()){ echo $path."\n"; //code to gather info } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.