List files of a directory

dirlist.php
<?php
 
  echo 'Contents:<br />' . "\n";
  $d = dir ('./');
 
  while (false !== ($entry = $d->read())) {
    if (is_dir($entry)) {
 
    } else {
      $ext = strtolower(substr($entry, strrpos($entry, '.')));
      if (in_array($ext, array('.jar','.png','.gif','.jpg'))) {
        echo '<a href="' . $entry . '">' . $entry . '</a><br />' . "\n";
      }
    }
 
  }
 
?>

 
snippets/php/listfiles.txt · Last modified: 2010-01-15 14:41.28 by mbirth
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki Contents powered by Club-Mate Contents powered by BassDrive.com Labelled with ICRA