用PHP只列出文件夹中的某些文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用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. ?>

以上是关于用PHP只列出文件夹中的某些文件的主要内容,如果未能解决你的问题,请参考以下文章