Hiding PHP Text

Dilemma:

I am using external text files from .swf files, which is not a problem. However, I have built a client backend that allows the client to edit the .txt files.

These files start with ‘myText=’ and end with ‘&’

I have already run into problems with the client either deleting those strings or screweing them up somehow, so I changed it so that when the file saves, it adds the strings at the front and end of the file.

But when the client opens the file, I want those two strings deleted from the file when they open it to edit. How can I do a simple find and replace before the file shows up?

I am kinda new to php, but here is my code:

if(($user == $u || $user == "") && $edit) // if an edit link was clicked
{
	$fp = fopen($path.$pathext.$edit, "rw");
	$oldcontent = fread($fp, filesize($path.$pathext.preg_replace($patterns, $replacements).$edit));
	$string = $oldcontent;
	$patterns[0] = '/myText=/';
	$patterns[1] = '/&/';
	$replacements[1] = '';
	$replacements[0] = '';
	
	fclose($fp);