-2

Possible Duplicate:
Detect language from string in PHP

How do I change the class of a textarea based on the language it contains (arabic, spanish, etc)?

Community
  • 1
  • 1

1 Answers1

2

Your orignial question mentions arabic.

If by detecting language you mean arabic vs. english characters, then you can use this:

preg_match('/[\x{0600}-\x{06FF}]/ui', $string)

Considering your input is in UTF-8 encoding, the character range for arabic is U+0600 to U+06FF, for some other language it's another set of characters, etc.

jadkik94
  • 7,000
  • 2
  • 30
  • 39