Kod
<?php
$file = file("data.txt");
$file = array_reverse($file, true);
foreach($file as $value) {
$exp = explode("`",$value);
echo $exp[0]."
".$exp[1]."";
}
?>
$file = file("data.txt");
$file = array_reverse($file, true);
foreach($file as $value) {
$exp = explode("`",$value);
echo $exp[0]."
".$exp[1]."";
}
?>
Wszystko jest ładnie, pięknie - ale chciałbym, aby wyświetlane było np. 5 ostatnich wpisów. Dlatego też zmodyfikowałem ten oto kod do tej postaci:
Kod
<?php
$file = file("data.txt");
$file = array_reverse($file, true);
$end = 5;
foreach($file as $value) {
++$i;
if($i <= $end) {
$exp = explode("`",$value);
echo $exp[0]."
".$exp[1]."";
}
}
?>
$file = file("data.txt");
$file = array_reverse($file, true);
$end = 5;
foreach($file as $value) {
++$i;
if($i <= $end) {
$exp = explode("`",$value);
echo $exp[0]."
".$exp[1]."";
}
}
?>
I działa on, tyle że tylko za 1 razem. Gdy na tej stronie chcę wrzucić drugie miejsce, w którym będą wyświetlane dane z innego pliku, ten trik już nie działa. Jak powinien wyglądać ten kod, aby było poprawnie?