Posted By

kidmizere on 07/27/13


Tagged

php list folder files


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Priestd09
IMPGTX


List only certain files in a folder with PHP


 / Published in: PHP
 

Lists only certain files extensions as links on a page from a defined folder

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

Report this snippet  

You need to login to post a comment.