]*>)(.*?)()(.*)$#is', $html, $matches)) {
$styles = array_merge(array($matches[2].process_style_content($matches[3]).$matches[4]),
process_style($matches[5]));
$html = $matches[1].$matches[5];
};
return $styles;
}
function process_style_content($html) {
// Remove CDATA comment bounds inside the
$html = preg_replace("##is","",$html);
// Remove HTML comment bounds inside the
$html = preg_replace("##is","",$html);
// Remove CSS comments
$html = preg_replace("#/\*.*?\*/#is","",$html);
// Force CDATA comment
$html = '';
return $html;
}
function insert_styles($html, $styles) {
// This function is called after HTML code has been fixed; thus,
// HEAD closing tag should be present
$html = preg_replace('##', join("\n", $styles)."\n", $html);
return $html;
}
?>