Saving an array as a file
| From: | Jeff Demel | Date: | Wed, 01 Nov 2000 21:04:33 +0000 |
| Subject: | Saving an array as a file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-23241@lists.php.net to get a copy of this message | ||
Okay, here's my last dumb newbie question for today - maybe.
I see how to use file() to open a text file as an array of strings with each
line an array element. That's great. So I make my changes with whatever
code to one or more array elements. Now, um, what do I do to save the
changes back to the file?
Example (not exactly what I'm really doing, but way simplified for clarity):
//open file as an array
$arrTextFile = file("test.txt");
//modify array
$arrText[0] = ereg_replace("this","that",$arrText[0]);
$arrText[1] = ereg_replace("this other","that other",$arrText[1]);
//save modified array back to test.txt file
??so what goes here??
Maybe there's a better way to do this, I don't know. But I need to find a
way to 1)find a specific line in a file (by matching a string value), modify
a different portion of that line only - replacing part of the string with
something else, and then saving the file.
TIA
-Jeff