Created
February 22, 2018 19:00
-
-
Save simbalinux/5b4cec2b8b29cc5f1f95d6bebefa15bb to your computer and use it in GitHub Desktop.
push last x lines of open file to new array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$lines=array(); | |
$fp = fopen("../log/simplelogger.log", "r"); | |
//tail off last x lines of the log file | |
while(!feof($fp)) | |
{ | |
$line = fgets($fp); | |
array_push($lines, $line); | |
if (count($lines)>10) | |
array_shift($lines); | |
} | |
fclose($fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment