ultraloveninja Posted July 3, 2012 Share Posted July 3, 2012 I am using scandir to scan two folders and then output the HTML. I can get it to work for one directory (the thumbnails) but I'm not sure how to get the other directory to output the array. Here's my code: <?php $dir2 = 'basement-pics'; $scan2 = scandir($dir2); $dir = 'basement-pics/thumbs/'; $scan = scandir($dir); for ($i = 0; $i<count($scan); $i++) { if ($scan[$i] != '.' && $scan[$i] != '..') { echo '<a href="' . $scan2 . '"><img src="basement-pics/thumbs/' . $scan[$i]. '" /></a>'; } }; ?> This is new ground for me so any help is greatly appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/265170-scandir-with-two-arrays/ Share on other sites More sharing options...
xyph Posted July 3, 2012 Share Posted July 3, 2012 You probably want to use $scan2[$i] as well. Quote Link to comment https://forums.phpfreaks.com/topic/265170-scandir-with-two-arrays/#findComment-1358882 Share on other sites More sharing options...
ultraloveninja Posted July 3, 2012 Author Share Posted July 3, 2012 Ahhh...ok. So, how does that work then? Is it because $i is already in the for loop? Quote Link to comment https://forums.phpfreaks.com/topic/265170-scandir-with-two-arrays/#findComment-1358884 Share on other sites More sharing options...
xyph Posted July 3, 2012 Share Posted July 3, 2012 You'd have to read more about arrays to understand what you're doing before I can really explain how it works. http://php.net/manual/en/language.types.array.php Quote Link to comment https://forums.phpfreaks.com/topic/265170-scandir-with-two-arrays/#findComment-1358890 Share on other sites More sharing options...
ultraloveninja Posted July 3, 2012 Author Share Posted July 3, 2012 Ok. I'll have to read up on that some more. Thanks for your help tho! Quote Link to comment https://forums.phpfreaks.com/topic/265170-scandir-with-two-arrays/#findComment-1358900 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.