I am writing some code and I have to write a number in a specific line here that I have done so far: < / P>
& lt ;? Php $ statsloc = getcwd () "/stats/stats.txt"; $ Handle = fopen ($ statsloc, 'r +'); ($ Linei = 0; $ linei & lt; $ zone; $ linei ++) for $ line = fgets ($ handle); $ Line = trim ($ line); Echo $ line; $ Line ++; Echo $ line; I do not know how to continue after this.
You can use the file to get the file as an array of lines , Then change your line, and rewrite the whole lot in the file again.
& lt ;? Php $ filename = getcwd () "/stats/stats.txt"; $ Line_i_am_looking_for = 123; $ Lines = file ($ filename, FILE_IGNORE_NEW_LINES); $ Rows [$ line_i_am_looking_for] = 'my modified row'; File_put_contents ($ filename, implode ("\ n", $ rows));
Comments
Post a Comment