hello,

Aim- To write a message "hello" in 1st line of text file which will automatic make the 1st line = "hello" , and the old text in 1st line which was "first" will come in second line , and the text in 2nd line will come to third line.... and so on..

example: we have a file abc.txt , which have 1st line = "hello"

now i want to write 1st line = "first" and the old text in 1st line which is "hello" must come in 2nd line automatic.

can anyone tell me what changes i need in the code below?

*[I want to do it without reading data of abc.txt file]*

$my_file = "abc.txt";
$handle = fopen($my_file, 'a');
$ggg = "first";
fwrite($handle, $ggg);
fclose($handle);