<?php

$doc = new DOMDocument();

$str[] = '<style type="text/css"></style>';
$str[] = '<style type=text/css></style>';
$str[] = '<style TYPE="TEXT/CSS"></style>';
$str[] = '<style TYPE=TEXT/CSS></style>';

foreach ($str as $myHtml) {

echo "before ", $myHtml, PHP_EOL;

$doc->loadHTML($myHtml, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);

removeAttr("style", "type", $doc);

echo "after: ", $doc->saveHtml(), PHP_EOL;

}

function removeAttr($tag, $attr, $doc) {
    $nodeList = $doc->getElementsByTagName($tag);
    for ($nodeIdx = $nodeList->length; --$nodeIdx >= 0; ) {
         $node = $nodeList->item($nodeIdx);
         $node->removeAttribute($attr);
    }
}