We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

fris on 11/16/07


Tagged


Versions (?)


Who likes this?

6 people have marked this snippet as a favorite

vali29
skywalker
helloyj
digiloper
JimiJay
carlosabargues


count number of files in a directory


Published in: PHP 


  1. <?
  2. $dir = "videos/";
  3. $count = 0;
  4. if(is_dir($dir)) {
  5. if($handle = opendir($dir)) {
  6. while(($file = readdir($handle)) !== false) {
  7. $count++;
  8. }
  9. closedir($handle);
  10. }
  11. }
  12. echo $count;
  13. ?>

Report this snippet 

You need to login to post a comment.