I am looking to modify this php code to do a recursive \"search for and display image\" on a single, known, directory with an unknown amount of sub-directories.
He
Some time ago I wrote this function to traverse a directory hierarchy. It will return all file paths contained in the given folder (but not folder paths). You should easily be able to modify it to return only files whose name ends in .jpg.
function traverse_hierarchy($path)
{
$return_array = array();
$dir = opendir($path);
while(($file = readdir($dir)) !== false)
{
if($file[0] == '.') continue;
$fullpath = $path . '/' . $file;
if(is_dir($fullpath))
$return_array = array_merge($return_array, traverse_hierarchy($fullpath));
else // your if goes here: if(substr($file, -3) == "jpg") or something like that
$return_array[] = $fullpath;
}
return $return_array;
}