- substr_count: documentation ( source)
- var_dump: documentation ( source)
- preg_match: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$pattern = '(?:;?[a-z\d+#.-]+)+'; // Borrowed from @Hamza.
$tags =<<<TAGS
gggd
hfhfghg;hfhdfh
fgjfgjgf;hfhdfh;hfhdfh
fgjgfj;hfhdfh;hfhdfh;hfhdfh
hfhdfh;hfhdfh;hfhdfh;hfhdfh;hfhdfh
hfhdfh;hfhdfh;hfhdfh;hfhdfh;hfhdfh;hfhdfh
hfhdfh;hfhdfh;hfhdfh;hfhdfh;hfhdfh;hfhdfh;hfhdfh
hfhdfh;hfhdfh;hfhdfh;hfhdfh;hfhdfh;hfhdfh;hfhdfh;hfhdfh
TAGS;
var_dump(preg_match_all('/'.$pattern.'/', $tags));
if (preg_match('/'.$pattern.'/', $tags)) {
var_dump(substr_count($tags, ';'));
}