php - removing the h3 closing tag only after getting the source by file_get_contents -


i using file_get_contents html source of remote page using code below :

<?php     //get url     $url = "remotesite/static/section35.html";     $html = file_get_contents($url);     $doc = new domdocument(); // create domdocument     libxml_use_internal_errors(true);     $doc->loadhtml($html); // load html can add $html      $elements = $doc->getelementsbytagname('tbody');      $toremove = array();      // gather list of tbodys remove     foreach($elements $el)       if((strpos($el->nodevalue, 'desktop') !== false) && !in_array($el->parentnode, $toremove, true))         $toremove[] = $el->parentnode;                  foreach($elements $el)       if((strpos($el->nodevalue, 'recommended') !== false) && !in_array($el->parentnode, $toremove, true))         $toremove[] = $el->parentnode;        // remove them     foreach($toremove $tbody)       $tbody->parentnode->removechild($tbody);      echo $doc->savehtml(); // save new html ?> 

what want remove every h3 closing tage </h3> source before echo page thos way content appear properly

echo str_replace('</h3>','',$doc->savehtml()); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -