pseudo code:
defined_string = "Anrea"
replace_string = "Anonymous"
Open file "xyz.txt"
Read one line.
Compare line to a defined_string
If they match change line to replace_string
Loop to check for more, til end of file.
I've been staring at this code too long! Does anyone see anything wrong? I did have this working, but seem to have done something to make it quit working.
<?php
$findThis = "Anrea";
$handle = @fopen("xyz.txt", "r"); // Open file form read.
if ($handle) {
while (!feof($handle)) // Loop til end of file.
{
$buffer = fgets($handle, 4096); // Read a line.
if ($buffer <> "Anrea") // Check for string.
{
echo "$buffer"; // If not string show contents.
} else {
$buffer = $findThis; // If string, change it.
echo "$buffer"; // and show changed contents.
}
}
fclose($handle); // Close the file.
}
?>
Thanks for any help!
Anrea