I am currently trying to do a logfile where I wanna insert a reverse chronology style (newest items will be put on top of the list of all existing texts, and previous existing items will be pushed below), think of it like Facebook Page, where if you visit a Profile Page, you can see all his posts by latest -> oldest, instead of currently what I have is, oldest -> latest. Here's my code so far;
$date = date("d-m-Y H:i:s");
$file = 'logfile.txt';
if (file_exists($file)) {
$current = file_get_contents($file);
$current .= PHP_EOL.$date;
file_put_contents($file, $current);
} else {
file_put_contents($file, $date);
}