Posted By

xhiena on 03/11/11


Tagged

list folder content


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

xhiena
mikael12
jirirybar


List folder content


 / Published in: PHP
 

URL: http://xhiena.net/index/php-mostrar-contenido-directorio/

  1. <?php
  2. //folder you want to list
  3. $path=".";
  4. //extension you don't want to list
  5. $no_mostrar=Array("","php");
  6.  
  7. $dir_handle = @opendir($path) or die("Error Opening $path");
  8. while ($file = readdir($dir_handle)) {
  9. $pos=strrpos($file,".");
  10. $extension=substr($file,$pos);
  11. if (!in_array($extension, $no_mostrar)) {
  12. echo "<a href=\"$file\" id=\"enlace_$file\" title=\"$file\">$file</a><br />";
  13. }
  14.  
  15. }
  16. closedir($dir_handle);
  17. ?>

Report this snippet  

You need to login to post a comment.