Great for getting, say a list of Word docs available for downloading in a directory, and creating
links to them.
function listFilesInDir($start_dir)
{
/*
returns an array of files in $start_dir (not recursive)
*/
$files = array();
$dir = opendir($start_dir);
while(($myfile = readdir($dir)) !== false)
{
if($myfile != '.' && $myfile != '..' && !is_file($myfile) && $myfile !
= 'resource.frk' && !eregi('^Icon',$myfile) )
{
$files[] = $myfile;
}
}
closedir($dir);
return $files;
}
?>
Example:
$dir = 'downloads/wordDocs/public/topic_1';
$wordDocs = listFilesInDir($dir);
foreach($wordDocs as $key => $fileName)
{
echo "{$fileName}
";
}
?>