Computing.Net > Forums > Web Development > readdir PHP

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

readdir PHP

Reply to Message Icon

Name: Jamie_McCoy
Date: July 15, 2005 at 22:49:39 Pacific
OS: XP
CPU/Ram: 512
Comment:

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 names

Any 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 !




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: readdir PHP

php upload script?? www.computing.net/answers/webdevel/php-upload-script/2083.html

PHP: Counting files in a directory. www.computing.net/answers/webdevel/php-counting-files-in-a-directory/2341.html

PHP Sort directory contents by date www.computing.net/answers/webdevel/php-sort-directory-contents-by-date/3483.html