Advertisement
Guest User

Untitled

a guest
Nov 28th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2.  
  3.         // open this directory
  4.         $myDirectory = opendir("ss");
  5.        
  6.         // get each entry
  7.         while($entryName = readdir($myDirectory)) {
  8.             $dirArray[] = $entryName;
  9.         }
  10.  
  11.         // close directory
  12.         closedir($myDirectory);
  13.  
  14.         //  count elements in array
  15.         $indexCount = count($dirArray);
  16.  
  17.         ?>
  18.        
  19.         <ul>
  20.  
  21.             <?php
  22.             // loop through the array of files and print them all in a list
  23.  
  24.            
  25.             for($index=0; $index < $indexCount; $index++) {
  26.                 $extension = substr($dirArray[$index], -3);
  27.                 for($i=0; $i<count($images) && $i<4; $i++) {
  28.               // Use $images[$i]
  29.               }
  30.                 if ($extension == 'jpg'){ // list only jpgs
  31.                     echo '<li><img class="img" src="ss/' . $dirArray[$index] . '" alt="Image" /><span>' . $dirArray[$index] . '</span>';
  32.                 }  
  33.             }
  34.             ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement