How to put a limit for writing in a file, if it hit the limit then remove the last line..
As example here's a file:
Line 3
Line 2
Line 1
i want to max line it for 3 lines only.. so when i write a new line using any append functions it removes the last line.. Let's say i just wrote a new line ( Line 4 ).. so it goes to the last one and remove it, result should be :
Line 4
Line 3
Line 2
And for a new written line (Line 5):
Line 5
Line 4
Line 3
numeric lines is not required, i just want to remove the last line if there's a new added line via an append functions (file_put_contents / fwrite) and max it by 3 or a specific number i give