Page 1 of 1

Files

Posted: Thu Jan 23, 2003 6:01 pm
by uberpolak
Does anybody know of a function that would get the number of files in a given directory? I've been unable to find such a function.

Posted: Thu Jan 23, 2003 6:59 pm
by mydimension
i don't believe there is one. try this though:

Code: Select all

function fileCount($dir) {
  $dirHandle = opendir($dir);
  $fileCount = 0;
  while (($file = readdir($dirHandle)) !== FALSE) {
    $fileCount++;
  }
  return $fileCount;
}
note: not tested