Page 1 of 1

How to write into file on perfect position

Posted: Thu Aug 13, 2009 3:26 am
by Naeem
I have file like this:

Code: Select all

<?php
$database = "Writing Text here";
 
I want to that when user submit input it's write into $database = "writing text here"; using fwrite function how to do that?
Thanks.

Re: How to write into file on perfect position

Posted: Thu Aug 13, 2009 3:50 am
by onion2k
If that's the entire file then it's probably easiest just to rewrite the whole thing. Eg

Code: Select all

fputs($file, "<?php\n\$database = \"".$value."\";");

Re: How to write into file on perfect position

Posted: Thu Aug 13, 2009 3:55 am
by Naeem
No it's not a entire file i just want to write the input data here only:

Code: Select all

$database = "Writing Text here"