So I'm trying to run website and I need a script which is showing the newest file in the folder.
Now I've got something like that:
- Code: Select all
include <?php
if ($handle = opendir('../art/')) {
while (false !== ($file = readdir($handle))) {
if(is_file('../art/'.$file) && (($kiedy=filemtime('../art/'.$file))>$najnowszy)){
$najnowszy=$kiedy; $najnowszy_nazwa=$file;
}
}
closedir($handle);
}
echo 'Najowszy plik to: '.$najnowszy_nazwa.', bo z dnia: '.date ("M-d-Y G:i:s", $najnowszy);
include '$najnowszy';
?>
And on my website I can see the which file is the newest - but the file is not showing up - means include function doesn't work and I don't know why.
I'm new in php so I can't solve this problem on my own.
And I also don't know how to make this script to show the second newest file.
HELP PLX


