title: Counting the number of specific characters inside string
body: <p>I'm sorry, I just found a new problem due to my question about:
  <a href="https://stackoverflow.com/questions/16160282/get-the-number-of-sepecific-string-inside-string/16160305?noredirect=1#comment23094348_16160305">Get The Number of Sepecific String Inside String</a>.</p>
  
  <p>I have been trying hard, how to find the number of specific character inside a string? The case something like this.</p>
  
  <pre><code>function get_num_chars($char) {
      $string = '120201M, 121212M-1, 21121212M, 232323M-2, 32323K, 323232K-1'
  }
  </code></pre>
  
  <p>If I pass <code>get_num_chars(M) would return 2</code> 
  If I pass <code>get_num_chars(M-1) would return 1</code></p>
  
  <p>I tried <code>count_chars()</code>, <code>substr_count()</code> but it doesn't work. </p>