PDA

View Full Version : Echo files in a directory?



manmohanjit
10-23-2009, 03:32 AM
Hello,

How do I echo all the files in a directory? I am a beginner at all this, so forgive me.

Thanks.

djr33
10-23-2009, 05:06 AM
http://www.php.net/manual/en/function.opendir.php
Look at the usage example.

manmohanjit
10-23-2009, 05:46 AM
http://www.php.net/manual/en/function.opendir.php
Look at the usage example.

Ok, thanks. Will look into it.

techietim
10-23-2009, 11:48 AM
$files = glob('*.*');
$files = array_filter($files, 'is_file');

if(count($files))
{
echo '<ul>';
}
foreach($files as $file)
{
echo '<li>' . basename($file) . '</li>';
}
if(count($files))
{
echo '</ul>';
}