class.readdir.php:
<?php
 class readdir {
  var $aantaldirs;
  var $aantalfiles;

  function lees($startdir = "./") {
   $handle = opendir($startdir);

   while(false != ($read = readdir($handle))) {
    if($read != "." && $read != "..") {
     if(is_dir($startdir.$read)) {
      $this->aantaldirs++;
      $files['dirs'][] = $read;
     } elseif(is_file($dir.$read)) {
      $this->aantalfiles++;
      $files['files'][] = $read;
     }
    }
   }

   closedir($handle);
   return $files;
  }

  function stats($type) {
   if($type == "dirs") {
    return $aantaldirs;
   } elseif($type == "files") {
    return $aantalfiles;
   }
  }
 }

 $readdir = new readdir;
?>

voorbeeld.php:
<?php
 include("class.readdir.php");

 $read = $readdir->lees("map/naar/dir/");
 $stats = array("dirs" => $readdir->stats("dirs"), "files" => $readdir->stats("files"));
?>
<center>
<table border="0" cellpadding="5" cellspacing="0" width="80%">
 <tr>
  <td width="50%" valign="top">
   <table border="0" cellpadding="0" cellspacing="0" width="90%">
<?php
 foreach($read['dirs'] as $dir) {
?>
    <tr>
     <td><?php echo $dir; ?></td>
    </tr>
<?php
 }
?>
   </table>
  </td>
  <td width="50%" valign="top">
   <table border="0" cellpadding="0" cellspacing="0" width="90%">
<?php
 foreach($read['files'] as $file) {
?>
    <tr>
     <td><?php echo $file; ?></td>
    </tr>
<?php
 }
?>
   </table>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
 </tr>
 <tr>
  <td colspan="2" align="center"><?php echo "<b>".$stats['dirs']."</b> dirs en <b>".$stats['files']."</b> bestanden."; ?></td>
 </tr>
</table>
</center>