PHP rewind() Function

The rewind() function "rewinds" the position of the file pointer to the beginning of the file.This function returns TRUE on success, or FALSE on failure.

bool rewind ( resource $handle )

Sets the file position indicator for handle to the beginning of the file stream.

Note -

If you have opened the file in append ("a" or "a+") mode, any data you write to the file will always be appended, regardless of the file pointer position.

Example -

The above example will output something similar to : -

Foolly long sentence.

ParameterDescription
handleThe file pointer must be valid, and must point to a file successfully opened by fopen().