I'd like to preg_match all div ids following the p tag with name="groups". How do I write this expression in PHP? (The html is malformed so I can't use XPath ...)
<p name="groups">
<div id="55">fifty-five</div>
<div id="65">sixty-five</div>
<div id="75">seventy-five</div>
</p>
The ideal output would be something like:
array
55
65
75
array
fifty-five
sixty-five
seventy-five
Whilst using regex to parse html is usually not good, using it to match certain pieces of html for limited jobs can be fine.
Here's the regex:
<p name="groups">(\s*<div id="([0-9]+)">([a-z\-]+)</div>)+\s*</p>