Return to Snippet

Revision: 12292
at March 9, 2009 13:48 by fackz


Initial Code
//path to directory to scan
$directory = "../images/team/harry/";
 
//get all image files with a .jpg extension.
$images = glob("" . $directory . "*.jpg");
 
//print each file name
foreach($images as $image)
{
echo $image;
}

Initial URL


Initial Description
The .jpg extension can be changed to any extension. So if you want to pull out only .txt files, you just need to replace the .jpg with .txt. If you want to list ALL files, just remove the condition.

Initial Title
list all files in a directory

Initial Tags
list, files

Initial Language
PHP