Page 1 of 1

count specific files

Posted: Thu Jan 30, 2003 9:29 am
by lino
hi, using the code found at

http://www.evilwalrus.com/viewcode/181.php

what can I add to tell it to only count files with the prefix "bri_" in the directory?

thanks

Posted: Thu Jan 30, 2003 11:58 am
by lazy_yogi
This should work for what ur asking and with simpler code

Code: Select all

print getAllFiles(".");

function getAllFiles ($dir) {
      $d = opendir ("$dir");

      while ($file = readdir ($d)) {
            if (is_dir ($dir."/".$file)) continue;  // EDITED THIS MSG: ADDED THIS LINE
            if ($file == ".." || $file == ".") continue;
            if (preg_match('/^bre_/', $file)) $count++;
      }

      closedir ($d);
      return $count;
}