Hallo,
ich möchte eine Textdatei rückwärts einlesen.
Es funktioniert soweit, jedoch erhalte ich immer eine Fehlermeldung.
Wo ist mein Fehler?
Danke
PHP
<?php
namespace SHC\Command\Web;
use RWF\Request\Commands\PageCommand;
use SHC\Core\SHC;
class LogPage extends PageCommand {
protected $template = 'logpage.html';
protected $languageModules = array();
public function processData() {
$datei = "/var/www/log.txt";
$array = file($datei);
$linesCount = count($array);
$max =20;
$c = 1;
foreach($array AS $line_num => $line) {
$last_num = $linesCount - $c;
echo $array[$last_num] . "<br/>\n";
$c++;
if ($c >= $max) { break; }
}
$tpl->assign('log', $array);
}
}
Alles anzeigen