
Originally Posted by
ButtermilkJack
Hi, thanks for the reply. I don't want to put my html files in a database. That's the thing. I'm trying to find a way of doing it so that I can just keep them in the root folder.
A database would be total over kill for this. Use opendir to open the directory containing the html files and readdir to loop through the files in the directory. For each html file, use filectime to see when the file was last changed.
The basic code to get the file you want is:
PHP Code:
$dirname="/path/to/html/";
$filename="";
$filetime=0;
$dir=opendir($dirname);
while($file=readdir($dir))
{
if($file != '.' && $file != '..')
{
if(filectime($file) > $filetime)
{
$filename=$file;
$filetime=filectime($file);
}
}
}
print "$dirname$file\n";
This is a totally untested quick and dirty example
There is plenty of error checking that can be added (did the directory open, is the file html etc.) but it should get you pointed in the right direction without the pain of adding a database to the mix.