Aha - you don't want the include method ...
Well, I'd go about it like this - read the file until you get to the first tag, then set a switch. Keep reading the file and add the records to an array, until you hit the closing tag. Then exit from the file loop, and shove the textarea onto the page, using 'join' to glue the array into one field.
<?php
$fp = fopen ("file.html","r");
$foundit = false;
while ($data = fgets ($fp, 100)) {
// once the tag is found, add lines to array
if ($foundit) $edit_text[] = $data;
// closing tag, so out of here
if ($data=="<!--END EDITABLE-->") break;
// opening tag, so set switch
if ($data=="<!--EDITABLE-->") $foundit = true;
}
fclose ($fp);
echo "<TEXTAREA>",join("\r\n",$edit_text),"</TEXTAREA>";
?>
You may not need the \r\n in the join, just an empty "" might do.
You also may need to use the nl2br (I think) function after the form is returned, to replace newlines with <br> tags.
To put it back in the file afterwards, you'd need to read the existing file in, and write the lines unchanged to a new output file, until you hit the start tag. Then write the textarea contents to the output file. Then ignore input lines until you get to the end tag. Then read from here to the end of the input file, writing to the output file. Now you need to delete the old input file, and rename the output file to replace it.
<?php
$fpi = fopen ("file1.html","r");
$fpt = fopen ("temp.html","w");
$foundit = false;
while ($data = fgets ($fpi, 100)) {
// if not in the editable area, copy across
if (!$foundit) {
fputs ($fpt,$data);
// if end tag, set switch
if ($data=="<!--END EDITABLE-->") $foundit = false;
// if start tag, set switch, copy new content
if ($data=="<!--EDITABLE-->") {
$foundit = true;
fputs ($fpt, $textarea_contents);
}
}
fclose ($fpi);
fclose ($fpt);
... now the delete and rename ... but I can't recall the syntax!
?>
I suppose you'll tell me there will be several editable areas in each html page!? Well, that complicates it a bit, but it wouldnt be impossible. Several textareas / arrays etc would be necessary.
Having thought about it this far, I'm tempted to try the same process with my web sites - so as to give the less technical users the chance to submit content.