Ho riscritto il tuo codice in maniera più leggibile:
Codice PHP:
$conta_td = 1;
$numero_td = 1;
echo " <table class=\"table table-striped table-bordered table-hover\"> <tbody>";
$f = fopen("Func/form_ipn.log", "r");
while (!feof($f)) {
$array = explode(",",fgets($f));
$row = current( $array );
if ($conta_td == 1)
echo "<tr>";
echo"<td>$row </td>";
if ($conta_td == $numero_td) {
echo "</tr>";
$conta_td = 1;
} else {
$conta_td++;
}
}
if ($conta_td!= 1) {
while ($conta_td <= $numero_td) {
echo "<td> </td>";
$conta_td++;
}
echo"</tr>";
}
echo " </tbody></table>";
Spero tu sappia che, per come li hai messi, $conta_td e $numero_td rimangono sempre a 1 per tutto il tempo, e quindi l'else dentro il while e l'if fuori dall'while non sono mai eseguiti.
A parte questo, puoi estrarre le ultime N righe di un file in due secondi così, anziché usare while(!feof($f)) e fgets e current:
Codice PHP:
$N = 2;
$tutte_le_righe = file('Func/form_ipn.log');
$ultime_righe = array_slice($tutte_le_righe, -$N);
dove $tutte_le_righe è un array e $ultime_righe è un array ridotto estrapolando $N righe dalla fine dell'array.