Well, made a reverse_text function for you. Not perfect, I'm not that great myself. I'm quite sure it could be done much more simply.
<?php
function read_file_backwards($file,$lines) {
$ftext = file_get_contents($file) or die("Could not open file");
$lb = chr(10);
$lblist = array();
$bwtext = array();
$lblist[] = 0;
$offset = 0;
$len = strlen($ftext);
while (strpos($ftext,$lb,$offset)) {
$offset = (strpos($ftext,$lb,$offset)+1);
$lblist[] = ($offset-1);
}
$lblist = array_reverse($lblist);
if ($lines != 0) {
$lblist = array_slice($lblist,0,$lines);
}
$key = 0;
while ($key < count($lblist)) {
$bwtext[] = substr($ftext,$lblist[$key],(-$lblist[$key] + ((($key-1)>=0) ? $lblist[($key-1)] : $len) ) + 1);
++$key;
}
}
?>
I didn't know if you wanted the linebreaks trimmed or not. Just add an rtrim into the while loop if you do. The rest of the class should be a breeze, IMHO.
Edit - Realized I didn't explain how it works.
Searches for each occurence of the $lb char, and puts it into an array, along with a buffer 0 to make the script work. Then it simply uses substr() to extract each line. The math is pretty self explanator, with the exception of using the ternary operator. I used the ternary operator because the math wouldn't work on the first value, as -1 isn't a valid array index. Thus, I just use the length of the file.