Loop dans repertoire


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



Copy this code and paste it in your HTML
  1. $dir = 'images';
  2. $dirname = $dir;
  3.  
  4.  
  5. if ( $dir = opendir($dirname)) {
  6. while (false !== ($file = readdir($dir))) {
  7. if ($file != "." && $file != ".." ) {
  8.  
  9. $tableau[] = $file;
  10. // variable qui compte le nombre de fichiers dans le dossier
  11. $nbr = count($tableau);
  12. }
  13. }
  14. closedir($dir);
  15.  
  16. for ($i = 0 ; $i < $nbr ; $i++)
  17.  
  18. {
  19.  
  20. echo' <img src="'.$dirname.'/'.$tableau[$i].'" class="full" alt="&nbsp;" width="520" />';
  21.  
  22. }
  23. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.