function process_style(&$html)
{
    if (preg_match('#^(.*<style[^>]*>)(.*?)(</style>.*)$#is', $html, $matches)) {
        process_style($matches[3]);
        $html = $matches[1] . process_style_content($matches[2]) . $matches[3];
    }
}
Exemplo n.º 2
0
function process_style(&$html)
{
    $styles = array();
    if (preg_match('#^(.*)(<style[^>]*>)(.*?)(</style>)(.*)$#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(&$html)
{
    $styles = array();
    # kornev, wrong preg
    //  if (preg_match('#^(.*)(<style[^>]*>)(.*?)(</style>)(.*)$#is', $html, $matches)) {
    if (preg_match_all('/(<style[^>]*>)(.*?)(<\\/style>)/is', $html, $matches)) {
        foreach ($matches[2] as $k => $v) {
            $styles[] = $matches[1][$k] . process_style_content($v) . $matches[3][$k];
        }
        $html = preg_replace('/(<style[^>]*>)(.*?)(<\\/style>)/is', '', $html);
    }
    return $styles;
}