What is the best way to detect thai languange in strings using PHP? I think I'd have to use unicode block, Thai Unicode block (i.e. between U+0E01 and U+0E5B). But how can I apply this in PHP?
1条回答 默认 最新
- dsk920417 2014-07-17 03:22关注
You could use a regular expression script:
if (preg_match('/\p{Thai}/u', $text) === 1) { echo 'Contains a Thai character'; }
If you want to use the range then you can also do so:
if (preg_match('/[\u0E01-\u0E5B]/u', $text) === 1) { echo 'Contains a Thai character'; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报