I'm creating a simple chat room and my problem is I don't know how to remove lines in a file while keeping some of the rest.
After the file reaches 20 lines, the older lines start to be removed, and only the new lines are kept.
So the chat will always have 20 lines once it reaches it.
Can someone help me on how to do this.
here is what i have so far...
// Count total messages
$msgfile = "/path/to/file.txt";
$lines = file($msgfile);
$length = "count($lines)";
$total_length = "20";
if($length > $total_length) {
// remove lines
}