List Directory Contents

Submitted by:Jhon Brain

Date added:18 September, 2013

Category:PHP

PHP example for listing directory contents

Tags: directory , contents

Code Snippet:

function list_files($dir)  
{
if(is_dir($dir))
{
if($handle = opendir($dir))
{
while(($file = readdir($handle)) !== false)
{
if($file != "." && $file != ".." && $file != "Thumbs.db")
{
echo '<a target="_blank" href="'.$dir.$file.'">'.$file.'</a><br>'."\n";
}
}
closedir($handle);
}
}
}
 
 

Comments