php - Problems to scan many images folders -
php - Problems to scan many images folders -
i have more 10 sections/articles in single pages , each section display 3 thumbs.
3 thumbs > linking > 1 images_main
images_main = thumb1, thumb2, thumb3
structure:
images |_______ 1stsection |__________ images_main |__________ img1 |__________ img2 |__________ img3 |___________ thumb |__________ img1 |__________ img2 |__________ img3
so, have wrote little code, working fine first section not working. not show right thumbs &/or images_main rest of sections.
it keeps showing images first folder, not matter if change: $smallsecond_dir = 'images/small225x341/ ** 2nd / 3rd / 4ththeme/ **';
gets images_main:
<h5> <?php $smallsecond_dir = 'images/small225x341/2ndtheme/'; $scan = scandir($smallsecond_dir); echo '<img src="' . $small225x341_dir . $scan[2] . '" alt="image" />'; ?> </h5>
gets thumbs:
<ul class="thumbs"> <?php $thumbs75x75_dir = 'images/thumbs75x75/2ndtheme/'; $scan = scandir($thumbs75x75_dir); ($i = 0; $i<count($scan); $i++) { if ($scan[$i] != '.' && $scan[$i] != '..') { if (strpos($scan[$i], '.jpg') !== false) { echo ' <li> <a href="' . $smallsecond_dir . $scan[$i] . '"> <img src="' . $dir . $scan[$i] . '" alt="' . $scan[$i] . '" /> </a> </li>'; } } }; ?> </ul>
how can scan each sections folder , show right thumb , right images_main?
thanks
long time ago wrote needing code ... maybe help
$subgalery = array(); function read_dir($dir){ global $subgalery; if(file_exists($dir)){ $opened = opendir($dir); while (($file = readdir($opened)) !== false){ if($file !== '.' && $file !== '..' && (is_dir($dir."/".$file))){ $subgalery[$dir."/".$file] = $file; read_dir($dir."/".$file); } } closedir($opened); }
returns array of forlders within folder
you can create without global, set within array_merge , homecoming ... old code
php debugging
Comments
Post a Comment