How can fwrite be used to write to the beginning of a file without appending anything?

When using `fwrite` in PHP, by default it appends content to the end of a file. To write to the beginning of a file without appending anything, you can use the `fopen` function with the mode set to 'r+' to open the file for reading and writing, then use `fseek` to move the file pointer to the beginning of the file before writing the content using `fwrite`.

$file = fopen('example.txt', 'r+');
if ($file) {
    fseek($file, 0);
    fwrite($file, "This will be written at the beginning of the file.");
    fclose($file);
}