Extracting data between HTML tags using regular expression
I have this example which successfully, takes the value from name and put in into three different arrays
$str = '<ul>
<li><a name="valuehere1" title="titlehere" href="/channel/london/">Link1</a></li>
<li><a name="valuehere2" title="titlehere" href="/channel/games/">Link1</a></li>
<li><a name="valuehere3" title="titlehere" href="/channel/sport/">Link1</a></li>
</ul>';
preg_match_all('/<li><a name="(.*)" title/', $str, $m);
print_r($m);
I am not hot having any luck with the code below. I am trying to extract all the data between <ul class="statelist">(.*) </ul> tags, but it is just returning two empty arrays
$data = '<ul class="statelist">
<li><a href="http://www.mymovingreviews.com/usa/alabama-movers-al-1">Alabama (45)</a></li>
<li><a href="http://www.mymovingreviews.com/usa/alaska-movers-ak-2">Alaska (4)</a></li>
<li><a href="http://www.mymovingreviews.com/usa/arizona-movers-az-3">Arizona (113)</a></li>
</ul>';
preg_match_all('/<ul class="statelist">(.*) <\/ul>/', $data, $m);
print_r($m);
Add s option to your regex
It will make your regex accept word wraps (\n character). (See the doc)