0

Im using Dom parser to extract content from html page within body tag something like:

$html = file_get_contents('index.php');

libxml_use_internal_errors(true);
$dom = new DOMDocument();
$dom->loadHTML($html);
$body = "";
foreach($dom->getElementsByTagName("body")->item(0)->childNodes as $child) {
    $body .= $dom->saveHTML($child);
}
echo $body;

but now I need to put modified $body variable back into index.php file and replace content within tag. Can I do that with file_put_contents()

Alko
  • 1,421
  • 5
  • 25
  • 51

0 Answers0