List all files in a directory tree under Win32:
function list_dir($dirname)
{
if($dirname[strlen($dirname)-1]!='\')
$dirname.='\';
static $result_array=array();
$handle=opendir($dirname);
while ($file = readdir($handle))
{
if($file=='.'||$file=='..')
continue;
if(is_dir($dirname.$file))
list_dir($dirname.$file.'\');
else
$result_array[]=$dirname.$file;
}
closedir($handle);
return $result_array;
}
Dan Gilbert wrote:
I looked through the manual and this forum for the answer to this, but I can't find it anywhere (or I don't know it when I see it).
I want to be able to retrieve a list of files in a directory. I need to have a list of "available" files appear to the user, and the "available" files are all the files in a specific directory.
I could enter all the filenames in a MySQL database and do a query, but I wanted to make it a bit simpler than that.
Is there a way to do a directory listing that I'm not finding?
Thanks in advance.
- Dan