I'm trying to return the count of a list. The list looks like:
<div id="list">
<ul>
<li class="some classes">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
I just can't figure out how to get a count of the li
tags. I don't care about the contents, just the count. This is what I have:
preg_match_all('!<div id="list">.*?<li.*?>.*?</li>.*?</ul>!', $content, $matches);
Ugly I know, and I only receive one match when I count($matches[0]);
Can anyone point out what I'm doing wrong and/ or why?
Thanks
EDIT: I know parsing HTML with regex is bad, but I have little choice in the matter right now.