I'm making a script which will make 6 copies of the filename.html in the given folder category using the given name , and then insert into each html file a specific text file taken from the $text array. I can manage the copy part but not the insert html function. Any help appreciated!
Ideally I would like it to insert the text between certain tags in the html file, for example between the <!-- begin --> and <!-- end --> tags or just replace some text (example - <<TEXTHERE>> ) in the html with the specific text. I've read the manual and the back posts but havent been able to manage it.
<?php
// input the category $category and filename $name to submission.php3 through form
// Defining text to be replaced for each copy
$text[1] = "abc";
$text[2] = "efg";
$text[3] = "hij";
$text[4] = "klm";
$text[5] = "nop";
$text[6] = "qrs";
// THIS FIRST PART MAKES A COPY OF THE filename.html WITH GIVEN NAME IN GIVEN FOLDER
$i = 1;
while ($i < 7) {
$source = "/home/mydomain/files/filename.html";
$dest = "/home/mydomain/files/$category/$name$i.html";
if ( copy($source, $dest) ) {
echo "<b>$i - http://www.mydomain.com/files/$category/$name$i.html</b> <br>$text[$i]<br><br>";
} else {
echo "unsuccessfully copied.";
}
// THIS PART IS SUPPOSED TO WRITE TEXT INTO HTML FILES - NOT SURE HOW TO DO IT!!
$fp = fopen ( $dest, "w+");
$fwrite ( $fp, $txt[$i]);
fclose ($fp);
$i++;
}
?>