Advertisement
imoda

Display all images in folder

Oct 3rd, 2011
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php  
  2.  
  3.     //getFiles('./');
  4.  
  5.     function getFiles($dir) {
  6.        
  7.         $files = array_diff(scandir($dir), array('.','..'));
  8.        
  9.         foreach ($files as $file) {
  10.            
  11.             if (is_dir($dir . $file)) {
  12.                
  13.                 getFiles($dir . $file . '/');
  14.             }
  15.             else {
  16.                
  17.                 //echo $dir . $file . "<br />";
  18.                
  19.                 $type = explode('.', $file);
  20.                
  21.                 $type = $type[count($type) - 1];
  22.                
  23.                 if ($type == 'jpg' || $type == 'png' || $type == 'jpeg' || $type == 'gif') {
  24.                
  25.                     echo '<image src="' . $dir . $file . '" />';
  26.                 }
  27.             }
  28.         }
  29.     }
  30.  
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement