1 minuta szukania w google, możesz to teraz podstawić do tablicy jeśli masz taką potrzebę
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<?php
  function paintUndersideOfFox($c = '.', $wcwd = false) {
  if($wcwd === false)
  $wcwd = substr($wcwd = $_SERVER['REQUEST_URI'], 0, strrpos($wcwd, '/') + 1);
  echo('<ul class="dirlist">');
  $d = opendir($c);
  while($f = readdir($d)) {
  if(strpos($f, '.') === 0) continue;
  $ff = $c . '/' . $f;
  echo '<li><a href="' . $wcwd . $ff . '">' . $f . '</a>';
  if(is_dir($ff)) paintUndersideOfFox($ff, $wcwd);
  echo '</li>';
  }
  echo('</ul>');
  }
  ?>
<title>Directory Listing</title>
<style type="text/css">
ul.dirlist, ul.dirlist li {
list-style-type: none;
padding-left: 1em;
}
</style>
</head>
<body>
<?php
  paintUndersideOfFox();
  ?>
</body>
</html>