der Ich: Aufspalten einer HTML-File in Doctype/Header/Body/...

Beitrag lesen

Hallo Ich,

preg_match('/^(.*?)(<html[^>]*>)([^<>]*)(<head[^>]*>)(.*?)(</head>)(.*)/is', $file, $matches);

// matches[0] = all
   // matches[1] = doctype (if there is) || NOT YET
   // matches[2] = <html> and attributes
   // matches[3] = Area between <html> and <head>
   // matches[4] = <head> and attributes
   // matches[5] = Content of <head>
   // matches[6] = </head> (not more ;)
   // matches[7] = everything after </head> (body,....)

gruß,

der ich

PS: ;-)