ben AT tech-space DOT net
24-May-2002 02:10
//lists all files in a directory with a given file name
convention
function list_dir($file_name_convention) {
switch
($file_name_convention) {
case 'dated_reports':
//matches
files like '5_23_2002.html'
$this_regexp =
"/[0-9]{1,}_[0-9]{1,}_[0-9]{4,}/";
break;
//add
more cases of file name conventions
}
$this_dir = dir('.');
if ($this_regexp != null) {
while ($file = $this_dir->read())
{
if (preg_match($this_regexp, $file)) {
$result_array[] = $file;
}
}
}
return
$result_array;
}