<?PHP $str = "<li><a href=\"http://https://convert.idontcarewhatyouthink.net/index.php\">Perschon</a></li>" echo substr_count($str, "li"); //result is 2 ?>
If you want to count a pattern of substrings and need to use regular expression,
the
<?PHP $str = "<li><a href=\"http://https://convert.idontcarewhatyouthink.net/index.php\">Perschon</a></li>" $cnt = preg_match_all("/\<[^\>]+\>/",$str, $mats); echo $cnt; //result is 4 ?>