this snippet let's you insert data at the beginning of a file.
it reads the contents and adds new data to the first line of the file.
after this it joins the lines and writes them back to the file again.

download options for file handling / write to first line of file

you can download the source as PHP file,

open the file as plain text in a new window or

get the code in a textarea to copy it.