caiba
OK.. i aint bin here for a while and this place has grown.... does anyone now if its possible to do a php script to write to a file on a certain line if u understand me
|
|
PHP Write to linecaiba
OK.. i aint bin here for a while and this place has grown.... does anyone now if its possible to do a php script to write to a file on a certain line if u understand me
napoleonvn
I don't understand your question exactely but if you want to write a line with php ,view example script below: <?php @$f=fopen("yourfile.txt","w");/* This line will open the file yourfile.txt if it is not available will create it*/ fwrite($f,"your text here"); fclose($f); ?> Slay
there are 3 modes to open a file "r" read "w" write ==> it will delete your old file and create a new one !! "a" append => try to open the file and create if not exist. you have got fseek to move into your file. but i recommend you to have a look in http://www.php.net/ the666bbq
there is no built-in way to write to a specific line in php. Probably the easiest way to achieve this is :
a) read the file you already have into an array with $arr = file($file); b) cut the array into two arrays based on the line you want to write to c) make the final array as the combination of part one, the new line, part two d) clear the file e) loop through the final array and write every item of the array as a new line. if you are not confident with it skip d) and write the array content to a temp file to compare the outcome Related topics
|