DBookatay Posted January 26, 2013 Share Posted January 26, 2013 Can someone please assist me. I found this script online, but need to modify it to only show 8 random (non repetitive) images, and keep failing. $dir = 'Albums/Kids/S/'; $file_display = array ('jpg', 'jpeg', 'png', 'gif'); $dir_contents = scandir($dir); shuffle($dir_contents); foreach ($dir_contents as $file) { $file_type = strtolower(end(explode('.', $file))); if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true) { $thumbs .= '<img src="'.$dir.'/'.$file.'" alt="" />'; } } Quote Link to comment https://forums.phpfreaks.com/topic/273654-random-image-script-from-a-directory/ Share on other sites More sharing options...
requinix Posted January 26, 2013 Share Posted January 26, 2013 What does your modified version look like? It's probably just one or two small fixes away from working. Quote Link to comment https://forums.phpfreaks.com/topic/273654-random-image-script-from-a-directory/#findComment-1408315 Share on other sites More sharing options...
DBookatay Posted January 26, 2013 Author Share Posted January 26, 2013 What does your modified version look like? It's probably just one or two small fixes away from working. I've tried so many variations Quote Link to comment https://forums.phpfreaks.com/topic/273654-random-image-script-from-a-directory/#findComment-1408317 Share on other sites More sharing options...
requinix Posted January 26, 2013 Share Posted January 26, 2013 Then you must have a lot of code you can show us. Feel free to post as many of them as you want. Quote Link to comment https://forums.phpfreaks.com/topic/273654-random-image-script-from-a-directory/#findComment-1408325 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.