Simple Writing a file issue

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

rahulalertpay
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Sep 18, 2013 11:13 am

Simple Writing a file issue

Postby rahulalertpay » Wed Sep 18, 2013 11:20 am

hello,

i need to save text at top of txt file , which will automatic makes 1st line text to be second line, 2nd line text to be 3rd line... so on.

For example, there is abc.txt file contains text in 1st line = hello

i need to write 1st line = "first"

and then 1st line which was "hello" , it must come to second line automatic.

what changes i need to do in the code below?

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

Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron