Reading directory contents
| From: | Ashley M. Kirchner | Date: | Sat, 12 Mar 2005 07:32:06 +0000 |
| Subject: | Reading directory contents | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-210583@lists.php.net to get a copy of this message | ||
A file system question for you folks.
We have a folder that contains the following structure of files for each of our sales reps in the company:
$TOP_FOLDER$/
/$SalesRep1/
/$Client1/
/File1.ext
/$Client2/
/File1.ext
/File2.ext
/$SalesRep2/
/$Client1/
/File1.ext
/$Client2/
/File1.ext
/File2.ext
/$Client3/
/File1.ext
/File2.ext
/File3.ext
etc., etc.
What I'd like to do it iterate through this $TOP_FOLDER$ and generate a page that looks as follows:
$SalesRep1 Clients: 2 Files: 3 Total size: xxx [MB/GB] $SalesRep2 Clients: 3 Files: 6 Total size: xxx [MB/GB]etc., etc. So I need to traverse through all the directories, while counting stuff at the same time (ignoring . and .. as I go) and at the end do some pretty display of all the information (I can figure that out later, I just need to collect data right now.) Right now, when I do an opendir() and readdir() I only get the contents of the top folder. How do I get the rest, and count the data as well? -- A