- substr: documentation ( source)
- var_dump: documentation ( source)
- strpos: documentation ( source)
<?php
$teste = 'sfgsdfgsdfgsdgf</body> </html>';
$pos = strpos($teste, '</body>');
if ($pos !== false) {
$html = substr($teste, 0, $pos);
var_dump($html . 'TESTETESTE' . substr($teste, $pos));
}