Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Ok here i go
Im working on a script, it reads through a directory, and loops through each folder it finds in that directry, then decends into each of those directories, locates files within them, and then stores that information in a few variables for use later on
It works great, ive had it loop through 6000 folders, but then thats were i ran into the problem
When it meets a file in the main directory, the loop ends for some reason... in theory it should just ignore the files and carry on reading the directory and dealing with each folder it finds, but its not !
For now im just going to give you the problem area of my code, too see if you can spot the error
<?php// defind directory to read
$dirHandle = opendir('.');$count = "1";
// start a loop based on each folder it finds
while ($memfolders = readdir($dirHandle)){
// ignore if $members is a file or a default folder such as . or ..
if (!is_file($memfolders) && ($memfolders != ".") && ($memfolders != "..") && ($count <= "1000")) {echo "$count
$memfolders
";
$count++;DO THE REST OF MY CODE
}
?>
Ok so that script is reading the directory of "." i can tell you that inside of that are 29,000 folders, and 2 files
the script has process and deleted 6342 folders... but now as its meeting the 2 files, the loop will not proceed
echo "$count
$memfolders
"; is producing this:1
.
1
..
1
error_log
1
readall.php
in theory it should be echoing out 1000 folder namesAny help will be greatly appreciated, i have 9 open projects i need to do, and cant proceed untill this one is done, so i await your brains to help me out
Thank You !

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |