Code Snippet > PHP
List Directory Content using PHP
This function able to loop through the folder you specify and display the content. Each file will be A tagged for quick access
PHP
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>'."
";
}
}
closedir($handle);
}
}
}
This code snippet was submitted by:
Kevin Liew is a web designer and developer and keen on contributing to the web development industry. He loves frontend development and absolutely amazed by jQuery. Feel free to say hi to me, or follow @quenesswebblog on twitter.
Leave a comment
Have something to say? Drop a comment! No HTML tags are allowed in the comment textfield.





















1 comment