I am currently using the following PHP code to return and format output from an .htm file:
<?php
$es = "</span>";
$lines = file("http://www.example.com/log.htm", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach($lines as $line){
list($date, $nick, $message) = explode(" ", $line, 3);
$str = substr($nick, 4, 1);
if($str=="+"){
$nickspan = '<span style="color:teal">';
$nick = substr_replace($nick, "", 2, 2);
echo("$date $nickspan$nick$es $message <br/>
");
} else {
if($str=="@"){
$nickspan = '<span style="color:#F20707">';
$nick = substr_replace($nick, "", 2, 2);
echo("$date $nickspan$nick$es $message <br/>
");
} else {
$str = substr($nick, 3, 1);
if($str=="*"){
$nickspan = '<span style="color:purple">';
$nick = substr_replace($nick, "", 1, 2);
echo("$date $nickspan$nick $message$es <br/>
");
} else {
$nickspan = '<span style="color:grey">';
$str = substr($nick, 2, 2);
if($str=="03"){
$nick = substr_replace($nick, "", 2, 2);
}
echo("$date $nickspan$nick$es $message <br/>
");
} } } }
?>
How would I change this to only display the last 50 lines, instead of listing absolutely everything from what is essentially a log file?