Freedom-n-Democrazy Posted September 23, 2011 Share Posted September 23, 2011 Is it possible to write to an exact line and column of a text file with PHP like with fwrite or something? Quote Link to comment https://forums.phpfreaks.com/topic/247688-writing-to-an-exact-ln-col-of-a-file/ Share on other sites More sharing options...
WebStyles Posted September 23, 2011 Share Posted September 23, 2011 Possible? yes. You'll probably have to read the entire text file into a variable, split it into lines, find the line you want, split it into columns, write your changes, then save the whole thing back into the text file. As long as you know how the text file is structured, it should be quite easy. (although not very practical, and error prone) Quote Link to comment https://forums.phpfreaks.com/topic/247688-writing-to-an-exact-ln-col-of-a-file/#findComment-1272064 Share on other sites More sharing options...
jcbones Posted September 23, 2011 Share Posted September 23, 2011 You could use file(), then select the line from the resulting array. You would then have to know the file specifics in order to be able to explode() the line down to get the right column. After all of this, you would need to put it all back together, and file_put_contents(). Quote Link to comment https://forums.phpfreaks.com/topic/247688-writing-to-an-exact-ln-col-of-a-file/#findComment-1272080 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.