TechniqueRead all the lines into an array and then reverse the array to loop through it (the code illuminates my meaning): <?php $f_contents = array_reverse (file ($fn)); foreach ($f_contents as $backwards_line) { print $backwards_line; } ?> CommentsThere are certain limitations on accessing files, and not being inherently able to loop backward through files is one of those limitations. Therefore, the simplest way is simply to load the file into an array of lines, reverse the array, and then process the array. You can also loop backward through the file lines to avoid the expense of array_reverse() : <?php $f_contents = file ($fn); for ($n = count ($f_contents) - 1; $n >= 0; $n--) print $f_contents[$n]; ?> |