I have a text file that I want to keep as a template, and not overwrite it. I'm trying to figure out how to write to a different file name. Seems the fwrite only writes back to the same file. Is fwrite the wrong function to use? This is part of my code:
$OPSname = $_POST['OPSname'];
$myTemplate = 'OPS_template.txt';
$fh = fopen($myTemplate, 'w+');
$data = fread($fh, filesize($myTemplate));
// update name field
$data = str_replace("@name", $OPSname, $data);
fwrite($fh, $data); // I need to write to a different filename
fclose($fh);