I'd like to write/read a rolling log file with PHP, where only the latest ~300 lines are stored/read and anything older is discarded. I'm not sure of the most efficient way of going about it - it needs to work fast as it's recording page hits on high traffic web sites.
Another PHP script will be regularly reading the log files and using the data for calculations. There are so many PHP file functions I'm confused as to where to start!
I don't think my hosting environment has access to commands such as tail
or awk
or similar, so a pure PHP solution is preferred. Any help appreciated!