What is the best practice for displaying the latest entry first when reading from a text file in PHP?

When reading from a text file in PHP, one way to display the latest entry first is to read the file into an array, reverse the array to reverse the order of the entries, and then iterate through the reversed array to display the entries in the desired order.

// Read the contents of the text file into an array
$lines = file('file.txt', FILE_IGNORE_NEW_LINES);

// Reverse the array to display the latest entry first
$lines = array_reverse($lines);

// Iterate through the reversed array to display the entries
foreach ($lines as $line) {
    echo $line . "<br>";
}