Using PHP, how can I extract all <div class="this">
even though it appears on different hierarchical levels in a HTML document?
<h3>Hello</h3>
<p>World</p>
<div class="this">
(lots of random markup, including other divs)
</div>
<div class="this">
(more random markup, including other divs)
</div>
<div class="inside">
<div class="this">
(even more random markup, including other divs)
</div>
</div>
<p>Bye.</p>
If it's not possible to achieve with regular expressions, does PHP have a built-in library that makes it easy to do something like this (pseudo-code)?
$result = find_all($html, "div", "this");
Desired result:
$result = array(
'<div class="this">
(lots of random markup, including other divs)
</div>',
'<div class="this">
(more random markup, including other divs)
</div>',
'<div class="this">
(even more random markup, including other divs)
</div>',
);