|
Generate Dynamic Index Files in PHP |
|
|
|
Tutorials / FAQs -
Programming
|
|
Page 1 of 2 This script will show you how to traverse the current directory so you can get information about it's files and directories. Create an array with the file info <?php $pathStr = $_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"]; //HTTP_HOST while (false !== ($filename = readdir($dh))) { if ( ( is_dir($filename) && $filename != ".") ) { $nFileKBsize = $nFileKBsize/1024; $aDirArr[$filename] = array(); $aDirArr[$filename]['filename'] = $filename; $aDirArr[$filename][] = ""; } else { $aFileArr[$filename] = array(); $aFileArr[$filename]['filename'] = $filename; $aFileArr[$filename]['filesize'] = number_format($nFileKBsize). " KB"; } else { $aFileArr[$filename]['filesize'] = ""; } } } } ?>
I'll show you how to generate the output on the next page.
|