kfreiman/php-file-seekable-iterator

There is no license information available for the latest version (dev-master) of this package.

Implementation of SeekableIterator for text files via generators

dev-master 2018-11-28 23:19 UTC

This package is not auto-updated.

Last update: 2024-11-10 06:02:01 UTC


README

It is implementation of SeekableIterator for text files. This library uses generators under hood, so it's suitable for large files.

How to use

$iterator = new FileSeekableIterator('/path/to/file');

$iterator->valid(); // true
$iterator->current(); // "16y3424ggg4\n" (based on test/files/data.txt example)
$iterator->key(); // 0

$iterator->seek(3);
$iterator->key(); // 3

Standart implementation

Note, this project was created for learning purposes and can be used as an example, but in most cases SplFileObject from Standard PHP Library is more useful.