<?php
$file = new SplTempFileObject();
for ($i = 0; $i < 100; $i++) {
$file->fwrite("Foo $i\n");
}
$file->rewind();
print_r(array(
array('line' => $file->key(), 'contents' => trim($file->fgets())),
array('line' => $file->key(), 'contents' => trim($file->fgets())),
array('line' => $file->key(), 'contents' => trim($file->fgets())),
));
$file->seek(50);
print_r(array(
array('line' => $file->key(), 'contents' => trim($file->fgets())),
array('line' => $file->key(), 'contents' => trim($file->fgets())),
array('line' => $file->key(), 'contents' => trim($file->fgets())),
));
preferences:
27.14 ms | 405 KiB | 5 Q