function htmlbodyInlineCss($html)
{
+ print_R($html);exit;
$dom = new DOMDocument();
@$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
- $body = $dom->getElementsByTagName('body');
- print_R($body);exit;
+ $html = $dom->getElementsByTagName('html');
+ $head = $dom->getElementsByTagName('head');
+ $body = $dom->getElementsByTagName('head');
+
+ if(!$head->length){
+ $head = $dom->createElement('head');
+ $html->item(0)->insertBefore($head, $body->item(0));
+ $head = $dom->getElementsByTagName('head');
+ }
+
$s = $dom->createElement('style');
$e = $dom->createTextNode($this->css_inline);
$s->appendChild($e);
- $body->appendChild($s);
+ $head->item(0)->appendChild($s);
return $dom->saveHTML();
}