gple Posted December 23, 2008 Share Posted December 23, 2008 Is there anyway to ouput all of the files associated in a directory. I have found some functions that allow you to do this but the server needs to be set up with PHP5 and my server currently is running on 4+. Any suggestions around this. Quote Link to comment https://forums.phpfreaks.com/topic/138210-scan-directory/ Share on other sites More sharing options...
flyhoney Posted December 23, 2008 Share Posted December 23, 2008 From the documentation... http://us.php.net/readdir <?php // Note that !== did not exist until 4.0.0-RC2 if ($handle = opendir('/path/to/files')) { echo "Directory handle: $handle\n"; echo "Files:\n"; /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { echo "$file\n"; } closedir($handle); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/138210-scan-directory/#findComment-722551 Share on other sites More sharing options...
.josh Posted December 23, 2008 Share Posted December 23, 2008 or glob Quote Link to comment https://forums.phpfreaks.com/topic/138210-scan-directory/#findComment-722552 Share on other sites More sharing options...
flyhoney Posted December 23, 2008 Share Posted December 23, 2008 Dammit CV, whenever I think I know what the hell I'm doing you come along with something I've never seen before. Quote Link to comment https://forums.phpfreaks.com/topic/138210-scan-directory/#findComment-722553 Share on other sites More sharing options...
gple Posted December 23, 2008 Author Share Posted December 23, 2008 works well but i am also returning "." and ".." why is that? Quote Link to comment https://forums.phpfreaks.com/topic/138210-scan-directory/#findComment-722628 Share on other sites More sharing options...
flyhoney Posted December 23, 2008 Share Posted December 23, 2008 '.' refers to the current directory and '..' refers to the parent directory. Just filter those out in your code. Quote Link to comment https://forums.phpfreaks.com/topic/138210-scan-directory/#findComment-722632 Share on other sites More sharing options...
gple Posted December 24, 2008 Author Share Posted December 24, 2008 question regarding this functionality. I currently have a directory that only has photos in it and I want to make a slideshow out of it. When clicking on the link, the first image in the directory appears but I would also like to have a next button that appears and clicking on it will go to the next image in the directory. there should also be a previous button that will let me go to the previous picture by clicking on it. Any suggestions on the best way to do this. Quote Link to comment https://forums.phpfreaks.com/topic/138210-scan-directory/#findComment-723201 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.