I\'m sorry, I just found a new problem due to my question about: Get The Number of Sepecific String Inside String.
I have been trying hard, how to find the number of
Try this
$string = '120201M, 121212M-1, 21121212M, 232323M-2, 32323K, 323232K-1';
$wordCounts = array_count_values(str_word_count($string,1));
echo $mCount = (isset($wordCounts['M-'])) ? $wordCounts['M'] : 0;
But here one thing You can just pass the 'M-' or 'M' not 'M-1' it is some workaround for what you want. Beacuse str_word_count matches exact word count been used.