Skip to content

Instantly share code, notes, and snippets.

@wallacemaxters
Last active September 3, 2015 12:15
Show Gist options
  • Save wallacemaxters/9f1ba0cf0f5d90adf5ee to your computer and use it in GitHub Desktop.
Save wallacemaxters/9f1ba0cf0f5d90adf5ee to your computer and use it in GitHub Desktop.
<?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