This function will grab a list of files/images/etc from a directory and list them as links to that file. Can be very handy, especially with images/image hosts :)
<?php
function list_files($dir)
{
if(is_dir($dir))
{
if($handle = opendir($dir))
{
while(($file = readdir($handle)) !== false)
{
if($file != "." && $file != ".." && $file != "Thumbs.db"/*pesky windows, images..*/)
{
echo '<a target="_blank" href="'.$dir.$file.'">'.$file.'</a><br>'."\n";
}
}
closedir($handle);
}
}
}
/*
To use:
<?php
list_files("images/");
?>
*/
?>
If you need more than just a list of files, the SPL has a DirectoryIterator object: http://www.php.net/manual/en/function.directoryiterator-construct.php
With it you can do more than just list files, you can also get information about their properties, ownership, permissions, whether or not php can write or read from the file etc.