I'm struggling to extract content from a string (stored in DB). Each div is a chapter, and the h2 content is the title. I want to extract separatly the title and the content of each chapter (div)
<p>
<div>
<h2>Title 1</h2>
Chapter Content 1 with standard html tags (ex: the following tags)
<strong>aaaaaaaa</strong><br />
<em>aaaaaaaaa</em><br />
<u>aaaaaaaa</u><br />
<span style="color:#00ffff"></span><br />
</div>
<div>
<h2>Title 2</h2>
Chapter Content 2
</div>
...
</p>
I've tryed with preg_match_all in php, but it doesn't work when i've standard html tags
function splitDescription($pDescr)
{
$regex = "#<div.*?><h2.*?>(.*?)</h2>(.*?)</div>#";
preg_match_all($regex, $pDescr, $result);
return $result;
}