PHP fseek() function
Definition and Usage
fseek() function locates in the opened file.
The function moves the file pointer from the current position to a new position, measured in bytes from the beginning of the file.
Returns 0 on success; otherwise returns -1. Note that moving to a position after EOF does not cause an error.
Syntax
fseek(file,offset,whence)
Parameters | Description |
---|---|
file | Required. Specifies the file in which to locate. |
offset | Required. Specifies the new position (measured in bytes from the beginning of the file). |
whence |
Optional. Possible values:
|
Kuvaus
whence Parametrit lisättiin PHP 4.0.0 jälkeen.
Vinkit ja huomiot
Vinkki:Käyttämällä ftell() löytääksesi nykyisen sijainnin.
Esimerkki
<?php $file = fopen("test.txt","r"); // Lue ensimmäinen rivi fgets($file); // Palatakseni tiedoston alkuun fseek($file,0); ?>