• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Counting Files

Is there any way to count the amount of files in one folder (eg = myfiles/counting) and return the number as a variable? (eg = $file_number)

~thanks everyone!
0
momonja
Asked:
momonja
1 Solution
 
VGRCommented:
sure

  $d = dir("yourdirectory"); // like ./hereandthere
  $i=0;
  while($entry=$d->read()) {
    if (($entry<>'.') and ($entry<>'..')) $i++;
  } // while
  $d->close();

// your number of files is in $i
0
 
momonjaAuthor Commented:
Thanks so much!!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now