1

I have some string:

$str = 'Xin chào';
$str2 = 'Xin chào 1';

In order to check if these two string variables is alphabetic, I've tried with ctype_alpha. However, both of ctype_alpha($str) and ctype_alpha($str2) are falsy.

Is there any other method that similars to ctype_alpha and working great with UTF-8?

Lewis
  • 14,132
  • 12
  • 66
  • 87

1 Answers1

2

this should work for you

preg_match('/^\p{L}[\p{L} _.-]+$/u', $str);

For more Information take a look at http://php.net/manual/en/regexp.reference.unicode.php

donald123
  • 5,638
  • 3
  • 26
  • 23