PHP rewind() Function

Definition and Usage

The rewind() function moves the file pointer to the beginning of the file.

If successful, returns true. If failed, returns false.

Syntax

rewind(file)
Parameter Description
file Required. Specifies the already opened file.

Example

<?php
$file = fopen("test.txt","r");
//Change the position of the file pointer
fseek($file,"15");
//Set the file pointer to 0
rewind($file);
fclose($file);
?>