Lister des fichiers en fonction de leur extension


/ Published in: PHP

List only certain files in a folder with PHP
Lists only certain files extensions as links on a page
from a defined folder


Copy this code and paste it in your HTML
  1. <?php
  2. /*
  3.  
  4. */
  5.  
  6. //Define directory for files listing
  7. //original example
  8. //$files = glob('/path/to/dir/*.xml');
  9. $files = glob('*.php');
  10. //to limit what is displayed you can use a diff listing:
  11. //$files = array_diff($files, array('index.php','opendb.php'));
  12.  
  13. foreach ($files as $value) {
  14. echo "<a href=http://changetoyoursite/$value>".$value."</a><br>";
  15. }
  16.  
  17. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.