I am loading a html file by file_get_contents and make some changes over it and then echo it. I want to add a javascript code to the file but I don't know how to do it. Thanks in advance.
<?php
$page = file_get_contents('http://www.example.com/index.html');
$doc = new DOMDocument();
$doc->loadHTML($page);
$node = $doc->getElementById('something');
$node->parentNode->removeChild($node);
echo $doc->saveHtml($doc), PHP_EOL;
?>