PHP japanese char validate

Viewed 46

I need to validate my input char if is Japanese. but it didn't work. Can you tell me where did I do wrong?

here is for check hiragana or kanji

function typeHiraWrong($group_name){
   $pattern='/^[x{3041}-\x{3096}\x{4e00}-\x{9faf}]+$/u';
   $test = preg_match($pattern, $group_name);
   return $test;
}

here is check for katakana

function typeKataWrong($group_name_kata){
   $pattern='/^[\x{4e00}-\x{9faf]+$/u';
   $test = preg_match($pattern, $group_name_kata);
   return $test;
}
1 Answers

Try this solution:

function typeKataWrong($group_name_kata){
   return preg_match('/^[\x{30A0}-\x{30FF}\x{3040}-\x{309F}\x{4E00}-\x{9FBF}]+$/u', $group_name_kata);
}
Related