title: Advanced string searching in PHP
body: <p>Assuming I have an array of colors:</p>
  
  <pre><code>$colors = array('black','yellow','red');
  $color = 'reddish';
  </code></pre>
  
  <p>How can I calculate the number of occurrence of them? Because <code>substr_count()</code> may be well detecting 'red', but 'reddish' won't be included. So I need to match the string precisely despite what's before or after it.</p>
  
  <pre><code>$string = implode(' ', $colors);
  echo substr_count($string, $color);
  </code></pre>