How can the issue of the last line of the file being outputted first be addressed in the PHP script?

The issue of the last line of the file being outputted first can be addressed by reading the file contents into an array, reversing the array to reorder the lines, and then outputting the lines in the correct order. This can be achieved by using the `file()` function to read the file into an array, using `array_reverse()` to reverse the array, and then looping through the reversed array to output the lines in the correct order.

$file_lines = file('file.txt');
$file_lines = array_reverse($file_lines);

foreach ($file_lines as $line) {
    echo $line;
}