In this article, you will learn how to move the position of the file pointer to the start of the file in PHP. The rewind() function in PHP rewinds the position of the file pointer to the beginning of the file.
what is the syntax of the REWIND function in php?
rewind(file)
Parameter | Description |
---|---|
file | Required. Specifies the open file |
examples of the REWIND function
Example 1. In this example, we rewind the position of the file pointer to the beginning of the file.
<?php
$file = fopen("test.txt","r");
//Change position of file pointer
fseek($file,"15");
//Set file pointer to 0
rewind($file);
fclose($file);
?>