Tagged: Counting Matches

Counting Matches in a String

Problem You want to find out how many times a particular pattern occurs in a string. Solution Use PHP’s preg_match_all() function: <?php // define string $html = “I’m <b>tired</b> and so I <b>must</b> go...