witam,
mam skrypt, który pobiera liste plików z folderów i wyświetla jako NAZWA PLIKU - DATA MODYFIKACJI ( poprzez filemtime) - USUŃ.
Skrypt działa ok, ale chciałbym aby wyświetlał pliki według daty modyfikacji - od najmłodszego do najstarszego.
Próbuję z różnymi funkcjami, tj. asort, ksort, ale mi sie nie udaje :/
Proszę o pomoc, bo już mi ręce opadają :/
Pozdrawiam, Lukasz.
<?php
function dirList ($directory)
{
// create an array to hold directory list
// create a handler for the directory
// keep going until all files in directory have been read
while ($file = readdir($handler)) {
// if $file isn't this directory or its parent,
// add it to the results array
if ($file != '.' && $file != '..' && is_file($directory."/".$file) == TRUE) $results[] = $file;
}
// tidy up: close the handler
// done!
return $results;
}
header('Content-type: text/html; charset=utf-8'); //musi byc bo rozne serwery sa z roznym kodowaniem
//<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
$html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
$html .= '<html>';
$html .= '<head>';
$html .= '<meta http-equiv="refresh" content="3;url=http: ..." />';
$html .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
$html .= '<title>';
$html .= "Pliki";
$html .= '</title>';
$html .= '</head>';
$html .= '<body BACKGROUND = "111.jpg">';
$html .= '<FONT FACE="arial">';
$html .= "<div>";
$aDir = "./myfiles";
$files = dirList($aDir);
{
$file = $aDir."/".$_GET["deleteFile"];
if ($file == $_SERVER["SCRIPT_NAME"])
{
$html .= "Nie mozna usunac tego pliku<br>";
}
{
$html .= "Usunieto $file<br>";
}
else
{
$html .= "Blad podczas usuwania pliku $file<br>";
}
}
foreach ($files as $val)
{
$html .= $val .' Odnotowano: '. date('H:i:s. d-F-Y.', filemtime($aDir."/".$val))."</a><hr><br>"; }
$html .= "</div>";
$html .= '</body>';
$html .= '</html>';
$html .= '</font>';
?>