Hi, I have a file (test.txt) that looks like: wfawfawaf [COLOR=Red]Unique Text bogfwg wfawgw gwa wa gagwgawwga ggawgwa wag gwawgwagwagwag gagwgwa End Unique Text[/COLOR] wfanwfa gawfwfafwa gaefwawfa Code (markup): I would to replace the red text with $testvar How do I do that? I could just read out the file using file_get_contents() then change the content with str_replace() then put it back with file_put_contents() Is that the best way? problem is, the file can get big, and it sounds like overkill
Read in blocks, especially if the text you are replacing only occurs once. You can then optimise by starting off at a certain point if you know roughly where the unique text is located etc.