I’m happy with the php code I’m currently using to display the file contents of a directory, but it currently says “list of files”, I would like to know how I could make that text disappear if the directory is empty, if thats possible. The code I am currently using is this:
<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$thelist .= '<a href="'.$file.'">'.$file.'</a>';
}
}
closedir($handle);
}
?>
<P>List of files:</p>
<P><?=$thelist?></p>
Thank you very much for any help.
Just put a condition around the last part: