What alternative methods can be used to insert data at the beginning of a file in PHP?

When inserting data at the beginning of a file in PHP, we can use the `file_put_contents()` function along with `file_get_contents()` to read the existing content of the file, prepend the new data, and then write it back to the file.

$file = 'example.txt';
$data = "New data to insert\n";

$current = file_get_contents($file);
file_put_contents($file, $data . $current);