Extracting cyrillic terms/keywords from text in php
<p>I'm trying to build keywords for my webpage and I want that keywords to be extracted from text.
I have  that function</p>

<pre><code>function extractCommonWords($string){
     $stopWords = array('и', 'или');

      $string = preg_replace('/ss+/i', '', $string);
      $string = trim($string); 
      $string = preg_replace('/[^a-zA-Z0-9 -]/', '', $string); 
      $string = strtolower($string); 
      preg_match_all('/\b.*?\b/i', $string, $matchWords);
      $matchWords = $matchWords[0];

      foreach ( $matchWords as $key=&gt;$item ) {
          if ( $item == '' || in_array(strtolower($item), $stopWords) || strlen($item) &lt;= 3 ) {
              unset($matchWords[$key]);
          }
      }  
      $wordCountArr = array();
      if ( is_array($matchWords) ) {
          foreach ( $matchWords as $key =&gt; $val ) {
              $val = strtolower($val);
              if ( isset($wordCountArr[$val]) ) {
                  $wordCountArr[$val]++;
              } else {
                  $wordCountArr[$val] = 1;
              }
          }
      }
      arsort($wordCountArr);
      $wordCountArr = array_slice($wordCountArr, 0, 10);
      return $wordCountArr;
}
</code></pre>

<p>Here is what I try:</p>

<pre><code>$text = "Текст кирилица";
$words = extractCommonWords($text);
echo implode(',', array_keys($words));
</code></pre>

<p>The problem is dosen`t work with cyrillic letters. How to fix that ?</p>
