Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function getDirTree($dir,$p=true) {
- $d = dir($dir);$x=array();
- while (false !== ($r = $d->read())) {
- if($r!="."&&$r!=".."&&(($p==false&&is_dir($dir.$r))||$p==true)) {
- $x[$r] = (is_dir($dir.$r)?array():(is_file($dir.$r)?true:false));
- }
- }
- foreach ($x as $key => $value) {
- if (is_dir($dir.$key."/")) {
- $x[$key] = getDirTree($dir.$key."/",$p);
- }
- }
- ksort($x);
- return $x;
- }
- $path = "./res/gallery/painting/";
- $tree = getDirTree($path);
- echo '<div id=gallery>';
- foreach($tree as $element => $eval) {
- if (is_array($eval)) {
- foreach($eval as $file => $value) {
- if (strstr($file, "png")||strstr($file, "jpg")||strstr($file, "bmp")||strstr($file, "gif")) {
- $item = $path.$file;
- $itemthumb = $path.'/thumbs/'.$file;
- echo '<a href="'.$item.'"><img src="'.$item.'" alt="'.$item.'"/></a>';
- }
- }
- }
- }
- echo '</div>';
Advertisement
Add Comment
Please, Sign In to add comment