Sixem

PHP Count Files In Folder / Directory

Jun 14th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.26 KB | None | 0 0
  1. <?php
  2.     $i = 0;
  3.     $dir = 'images/';
  4.     if ($handle = opendir($dir)) {
  5.         while (($file = readdir($handle)) !== false){
  6.             if (!in_array($file, array('.', '..')) && !is_dir($dir.$file))
  7.                 $i++;
  8.         }
  9.     }
  10. echo $i;
  11. ?>
Advertisement
Add Comment
Please, Sign In to add comment