I need a PHP regular expression pattern to select separately all lists <ul></ul>
from string.
The string is like:
Lorem ipsum dolor sit amet,...
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
Lorem ipsum dolor sit amet,...
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
....
I need to extract both lists and save them in array, so the result would look like:
$listsarray[0] = first list code from <ul> to </ul>.
$listsarray[1] = second list code, etc..
What I have tried, but this doesn't work as expected. If there is more than two lists, it selects first two as one (I don't know why, I'm a novice at regular expressions):
$content = 'the content like above...';
$pattern = '/<ul[^.]*<\/ul>/';
preg_match_all($pattern, $content, $listsarray)