Created
November 17, 2018 16:22
-
-
Save bosunski/af059302599436de2f473ff800056592 to your computer and use it in GitHub Desktop.
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 | |
$fileCache = "LastLine.txt"; | |
$oldLastLine = getLastLine($fileCache); | |
function getLastLine($cachePath) | |
{ | |
if (file_exists($cachePath)) | |
return file_get_contents($cachePath); | |
return 0; | |
} | |
function fileRead($path) { | |
$fileHandle = fopen($path, 'rb'); | |
while (($line = fgets($fileHandle)) !== false) { | |
yield rtrim($line, "\r\n"); | |
} | |
fclose($fileHandle); | |
} | |
$lastLine = 0; | |
$updates = ""; | |
foreach (fileRead(".gitignore") as $line) { | |
$lastLine++; | |
if ($lastLine > $oldLastLine) { | |
$updates .= $line . PHP_EOL; | |
} | |
} | |
file_put_contents($fileCache, $lastLine); | |
echo $updates; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment