<?php $inliner_bypass_matches_total = 0; $inliner_bypass_matches = array(); $the_html = '<style class="sp_bypassInliner">div.class {width:100%}</style>'; $dom = new DOMDocument(); $dom->formatOutput = false; $dom->preserveWhiteSpace = false; $dom->strictErrorChecking = false; $dom->validateOnParse = false; $the_html = str_replace(' ', '@nbsp;', $the_html); $dom->loadHTML(mb_convert_encoding('<?xml version="1.0" encoding="UTF-8"?>' . "\n" .$the_html, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); $nodes = $xpath->query("//*[contains(@class, 'sp_bypassInliner')]"); $node_count = $nodes->length; if ($node_count > 0) { // Work from the bottom up, so we don't mess anything up. for ($i=$node_count; $i>0; --$i) { $node = $nodes->item($i-1); $inliner_bypass_matches_total++; $html_fragment = $node->nodeValue; $inliner_bypass_matches[$inliner_bypass_matches_total] = $html_fragment; $inliner_bypass_tags = $dom->createDocumentFragment(); $inliner_bypass_tags->appendXML("<!--sp_bypassInliner$inliner_bypass_matches_total-->"); $node->parentNode->replaceChild($inliner_bypass_tags, $node); } $the_html = $dom->saveHTML($dom->documentElement); // $the_html = dom_savehtml_cleanup($the_html); } else $the_html = str_replace('@nbsp;', ' ', $the_html); echo $dom->saveHTML($the_html[0]);
You have javascript disabled. You will not be able to edit any code.