How can the rewind function in PHP be utilized when working with file manipulation?
When working with file manipulation in PHP, the rewind function can be utilized to reset the file pointer to the beginning of a file. This can be useful when you need to re-read or re-write the contents of a file without closing and reopening it.
$file = fopen("example.txt", "r+");
// Read file contents
echo fread($file, filesize("example.txt"));
// Rewind file pointer to the beginning
rewind($file);
// Write new content to the file
fwrite($file, "New content");
fclose($file);