So I have the following regex and I count the occurrences of matches like so:
preg_match_all("/".$toArray."/i", $input, $matches);
$count_matches = count($matches[0]);
However, I want to get only those matches that are unique. And applying array_unique()
to the following does not seem to work.
$count_matches = count(array_unique($matches[0]));
Does the key [0]
mess it up? If so how can I go round this?