5 November 2013

Check if text contains cyrillic characters in PHP. This example shows you how to do exactly that.

Source code viewer
  1. $str = 'test string for cyrillic зюя';
  2. $contains_cyrillic = (bool) preg_match('/[\p{Cyrillic}]/u', $str);
  3. if ($contains_cyrillic) {
  4. echo 'Contains cyrillic.';
  5. }
  6. else {
  7. echo 'Does not conain cyrillic.';
  8. }
Programming Language: PHP