If I have some html that looks like this:
<p>This is a paragraph:</p>
<ul> <li>Bullet one</li> <li>Bullet two</li> <li>Bullet three</li> </ul>
Is there a way to count the number of <li> tags? So that it returns 3?
preg_match_all('/<li(\s[^>]*)?>/i', $text, $matches); $li_count = count($matches[0]);