Last active
September 3, 2015 12:15
-
-
Save wallacemaxters/9f1ba0cf0f5d90adf5ee 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 | |
class FileObject extends SplFileObject { | |
public function tail($amount) | |
{ | |
$lastKey = $this->key(); | |
$this->seek(PHP_INT_MAX); | |
$end = $this->key(); | |
$start = $end - $amount; | |
// Set as last Line of iterations | |
$this->seek($lastKey); | |
return new LimitIterator($this, $start, $end); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment