I am currently using the PHP DOM to get the BODY tag from HTML.
$doc = new DOMDocument();
$doc->loadHTML($HTML);
$body = preg_replace("/.*<body[^>]*>|<\/body>.*/si", "", $HTML);
The above code completely gives me the html from the body tag for a given HTML.
Can I get the HTML tags with $body as an array?
If possible, I would use DOM – it will make your solution a lot more reliable and cleaner to use.
This should get your headed in the right direction (I’m not writing the solution for you, sorry):