Currently working in the directory.
";
//$dirhandle is the variable that stores which directory to read from
//This statement acquires the current working directory to read from and places it in $dirhandle
$dirhandle = opendir($directstring);
//readdir() returns a false value when it can't read a directory, so this statement will continue to
//loop until that time when readdir() returns false. That will happen when it finishes reading the directory
//or if it can't read it at all.
//$directory is the variable that is used to hold the name of what it readdir() is reading.
while( false!== ($directory = readdir($dirhandle)))
{
//this if statement checks to see if the file that was read was a directory or a file
if ( is_dir($directory) == true)
{
//if it was a directory, it parses through and ignores the directories "." and ".."
//"." is a self reference, and ".." is a reference to the parent directory. It ignores
//these because there's no use in displaying them.
if ( $directory != "." && $directory != ".." )
{
//Now we start displaying the names of the directories that were found with readdir()
echo "\t" . $directory . ":
";
$directstring = getcwd() . "/" . "$directory";
readdirectory($directstring);
}
}
elseif(is_file($directory) == true)
{
//Displays the files for linking
echo "\t" . $directory . "
";
}
}
closedir();
}
echo "
Directories:
";
$directstring = getcwd();
readdirectory($directstring);
?>