Thursday, June 7, 2012

How to detect Arabic language in PHP


$arabicChars = "ء|آ|أ|ؤ|إ|ئ|ا|ب|ة|ت|ث|ج|ح|خ|د|ذ|ر|ز|س|ش|ص|ض|ط|ظ|ع|غ|ف|ق|ك|ل|م|ن|ه|و|ى|ي|٫|ٮ|ٯ";


 $isArabic = mb_ereg(".*[$arabicCharsList].*", $str);



NOTE: you could detect any non-latin language by replacing the character list with the main characters of that language


2 comments: