joeysnacks Posted February 5, 2012 Share Posted February 5, 2012 Hi I am trying display thumbs from a directory, BUT , I cannot figure out how to show more then just .jpg. For example, how could I make this code show the following file extensions, .jpg .png .gif ? Here is the code spinet and if you could advise that would be awesome Thanks so much for your time in advance <?php $largeArray = glob("images/*.jpg"); $counter = 0; foreach (array_slice(glob("images/thumbs/*.jpg"),0,600) as $thumb) { echo ("<div class='thumbgall'><a href='$largeArray[$counter]' rel='lightbox'><img src='$thumb'/></a></div>"); $counter++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/256495-display-more-the-just-jpg-from-thumbs-with-glob/ Share on other sites More sharing options...
litebearer Posted February 5, 2012 Share Posted February 5, 2012 1. are there only images in the images and thumbs folder? 2. do the thumbs have the same name as the images? ie they have same name but are in different folders - images/apple.gif and images/thumbs/apple.gif Quote Link to comment https://forums.phpfreaks.com/topic/256495-display-more-the-just-jpg-from-thumbs-with-glob/#findComment-1314887 Share on other sites More sharing options...
QuickOldCar Posted February 6, 2012 Share Posted February 6, 2012 <?php $images = glob("images/{*.jpg,*.gif,*.png}", GLOB_BRACE); //print_r($images); $counter = 0; foreach (array_slice($images,0,600) as $thumb) { echo ("<div class='thumbgall'><a href='$images[$counter]' rel='lightbox'><img src='$thumb'/></a></div>"); $counter++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/256495-display-more-the-just-jpg-from-thumbs-with-glob/#findComment-1314902 Share on other sites More sharing options...
joeysnacks Posted February 6, 2012 Author Share Posted February 6, 2012 <?php $images = glob("images/{*.jpg,*.gif,*.png}", GLOB_BRACE); //print_r($images); $counter = 0; foreach (array_slice($images,0,600) as $thumb) { echo ("<div class='thumbgall'><a href='$images[$counter]' rel='lightbox'><img src='$thumb'/></a></div>"); $counter++; } ?> Thank you sir Quote Link to comment https://forums.phpfreaks.com/topic/256495-display-more-the-just-jpg-from-thumbs-with-glob/#findComment-1315003 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.