http://stackoverflow.com/a/2087136/1998086

-9 Removals
+8 Additions
<?php<?php
function DOMinnerHTML($element)function DOMinnerHTML(DOMNode $element)
{{
$innerHTML = ""; $innerHTML = "";
$children = $element->childNodes; $children = $element->childNodes;
foreach ($children as $child) foreach ($children as $child)
{ {
$tmp_dom = new DOMDocument(); $innerHTML .= $element->ownerDocument->saveHTML($child);
$tmp_dom->appendChild($tmp_dom->importNode($child, true));
$innerHTML.=trim($tmp_dom->saveHTML());
} }
return $innerHTML; return $innerHTML;
}}
?>?>
<?php<?php
$dom= new DOMDocument();$dom= new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->load($html_string);$dom->load($html_string);
$dom->preserveWhiteSpace = false;
$domTable = $dom->getElementsByTagName("table");$domTables = $dom->getElementsByTagName("table");
foreach ($domTable as $tables)foreach ($domTables as $table)
{{
echo DOMinnerHTML($tables); echo DOMinnerHTML($table);
}}
?>?>
Editor
Original Text
Changed Text