<html> <head> <title>Listing the Contents of a Directory with readdir()</title> </head> <body> <div> <?php $dirname = "."; $dh = opendir( $dirname ); while ( ! is_bool( $file = readdir( $dh )) ) { if ( is_dir( "$dirname/$file" ) ) { print "(D) "; } print "$file<br/>"; } closedir( $dh ); ?> </div> </body> </html>