-
Okay I hoped that wud grab your attention...
Now here's what I need:
How do I open up a txt and change a variable inside it, I don't mean like writing a new entry to it, but just changing a variable. eg:
this is the txt:
$var = 0
I want to open it up via php and make it this:
$var = 1
but I don't just wanna delete everything in it and write a new tag cuz I'll have alot more than that in the txt.
If you can help I'd be in your debt.
-
Senior Member
What I do for text files, is once I find the information I am looking for, I save the ENTIRE text file message in one variable, then I save the orriginal "section" of data that I want to replace in another variable, then when I have the new data I want to put in, I use php's str_replace function to replace the orriginal value with the new value in the whole thing, then I just write my new message to the text file! You can read about the str_replace function here: http://www.php.net/manual/en/function.str-replace.php
Good luck!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|