Here's my problem. I am scraping a website for data, and would like to use regex to get the contents of three similar divs. They are structured like this:
<div id="cphMain_pnlBreakfastItems" class="bp2-wdn-col-one-third">
<h4>blah blah</h4>
<span>content</span>
<span>other content</span>
</div>
<div id="cphMain_pnlLunchItems" class="bp2-wdn-col-one-third">
<h4>blah blah</h4>
<span>content</span>
<span>other content</span>
</div>
<div id="cphMain_pnlDinnerItems" class="bp2-wdn-col-one-third">
<h4>blah blah</h4>
<span>content</span>
<span>other content</span>
</div>
There are 3 separate divs: Breakfast, Lunch, and Dinner Items. I am trying to use preg_match to get them all as matches like this.
preg_match('/<div id="cphMain_pnl.*Items"[\s\S]*\/div>/s', $page, $match);
However, after running this, I get all three divs as one match instead of three separate matches. How can I get them as three separate matches?
I tried using DOM to do this, but when I got the contents of the divs, it had stripped the tags so I didn't know what content is what.