(PHP 5 >= 5.1.0)
SplFileObject::fseek — Seek to a position
Seek to a position in the file measured in bytes from the beginning of the file, obtained by adding offset to the position specified by whence .
The offset. A negative value can be used to move backwards through the file which is useful when SEEK_END is used as the whence value.
whence values are:
If whence is not specified, it is assumed to be SEEK_SET.
Returns 0 if the seek was successful, -1 otherwise. Note that seeking past EOF is not considered an error.
Example #1 SplFileObject::fseek example
<?php
$file = new SplFileInfo("somefile.txt");
// Read first line
$data = $file->fgets();
// Move back to the beginning of the file
// Same as $file->rewind();
$file->fseek(0);
?>