Image names in directory


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. if ($handle = opendir('Images/Slideshow')) {
  3.  
  4. while (false !== ($file = readdir($handle)))
  5. {
  6. if ( preg_match( "/[.]jpg$/", $file ) ) {
  7. preg_match( "/_(\d+)_(\d+)[.]/", $file, $found );
  8. ?>
  9. <div class="imageElement">
  10. <h3></h3>
  11. <p></p>
  12. <a href="#" title="open image" class="open"></a>
  13. <img src="Images/Slideshow/<?php echo $file; ?>" class="full" /></div>
  14. <?php
  15. }
  16. }
  17. closedir($handle);
  18. }
  19. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.