Easy Tutorial
❮ Func Filesystem Fgetcsv Php Mail ❯

PHP fseek() Function



Definition and Usage

The fseek() function positions the file pointer at a specified location in an open file.

This function moves the file pointer from its current position forward or backward to a new position, measured in bytes from the beginning of the file.

The function returns 0 on success and -1 on failure. Note that moving beyond the end of the file (EOF) does not result in an error.

Syntax

Parameter Description
file Required. Specifies the file in which to position the pointer.
offset Required. Specifies the new position (measured in bytes from the beginning of the file).
whence Optional. (Added in PHP 4). Possible values: SEEK_SET - Sets the position equal to offset. Default.<br> SEEK_CUR - Sets the position to the current position plus offset.<br> SEEK_END - Sets the position to the end of the file (EOF) plus offset (to move before the EOF, offset must be negative).

Tips and Notes

Tip: Use ftell() to find the current position!


Examples


❮ Func Filesystem Fgetcsv Php Mail ❯