daten aus verzeichnis lesen und sortieren
nox
- php
0 Tom
hy @all
möchte mittels php daten aus einem ordner (verzeichnis) lesen, und die daten nach datum (filemtime) sortieren
habe da mal was probiert.
die daten werden richtig geöffnet.
nur weiss ich nicht wie sortieren!
Sourcecode:
<?PHP
$verz = dir("txtdb/aktuell/");
$txt = array();
while($entry=$verz->read())
{
$txt[] = "txtdb/aktuell/".$entry;
}
array_shift($txt); //pfad punkt wird gelöscht aus array (.) -> i.o.
array_shift($txt); //verzeichnis punkte werden gelöscht aus array (..) -> i.o.
//Table beginn -> i.o.
echo "<table width='100%' border='0'>";
echo "<tr><td width='5%'></td>";
echo "<td width='625' height='15'><h1>News:</h1></td>";
echo "<td width='5%'></td></tr>";
//Ordnerinhalt in tabelle eingefügt -> i.o.
for($y=0;$y<count($txt);$y++)
{
//Dateiname, für ausgabe als titel -> i.o.
$map = $txt[$y];
$maplink = $map;
$fp = fopen($maplink,"r");
if ($fp)
{
//Tabellenfelder -> i.o.
echo "<tr><td width='5%'></td><td width='625'>";
echo "<fieldset><legend>" .$map. "</legend><p>";
while (!feof($fp))
{
$zeile = fgets($fp, 1000);
echo "$zeile";
}
echo "</td><td width='5%'></td></tr><tr><td width='5%'>";
echo "</td><td width='625' height='15'></td><td width='5%'></td></tr>";
fclose($fp);
}
else
{
echo "Datei: " .$map. " nicht gefunden";
}
}
$verz->close();
//Table end -> i.o.
echo "</table>";
?>
alles läuft soweit!
eben nur noch die sortierung nach datum (aktuellstes zuerst)
danke schon im voraus für die lösung ;)
greez nox
sers
schau mal auf:
http://www.php.net/manual/de/function.usort.php
soviel zu dem thema.. andre frage - warum machst du das ganze net mit MySQL ?