How would I insert text between two comments like the ones below with PHP. Thanks in advance.
<!-- BEGIN INSERT 1 -->
<!-- END INSERT 1 -->
This will do the job. It's using substr_replace(). You can read more about it here.
<?php
$stringToInsert = "tesssst";
$oldString = "<!-- BEGIN INSERT 1 --><!-- END INSERT 1 -->";
$newString = substr_replace($oldString, "-->" . $stringToInsert . "<!--", strpos($oldString, "--><!--"), strlen($stringToInsert));