<?php
  $dir = "./";
  if(!($fd = opendir($dir))){
    exit("Nie mogę otworzyć katalogu $dir!");
  }

  $arr = array();

  while (($file = readdir($fd)) !== false){
    $arr[] = $file;
  }

  sort($arr);
  closedir($fd);

  foreach($arr as $val){
    echo "$val<br>";
  }
?>
