N402KC Posted June 10, 2010 Share Posted June 10, 2010 Hi Guys, I have a Main folder called Templates. Inside of templates, I have a few hundred folders. Inside of all those folders is a file called screenshot.png. Can someone help me with my code. So far i have it echo'ing all of the folder names, But I need it to get into those folders, find screenshot.png, and show it kinda like a gallery. Please let me know if you can help. Thanks <?php $current_dir = "templates/"; $dir = opendir($current_dir); echo ("<p><h1>List of available files:</h1></p><hr><br />"); while ($file = readdir($dir)) { echo $file; } ?> Link to comment https://forums.phpfreaks.com/topic/204405-read-files-inside-a-folder-thats-inside-of-another-folder/ Share on other sites More sharing options...
kenrbnsn Posted June 10, 2010 Share Posted June 10, 2010 Use the glob function and then loop through the resultant array: <?php $x = glob('templates/*/screenshot.png'); print_r($x); ?> Ken Link to comment https://forums.phpfreaks.com/topic/204405-read-files-inside-a-folder-thats-inside-of-another-folder/#findComment-1070401 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.