I already searched here and found similar posts related to this post but i did not find a solution yet .
i tried this :
$text = "الحمد لله رب العالمين hello";
echo $is_arabic = preg_match('/\p{Arabic}/u', $text);
I add the unicode flag but if i add any English characters it is returning true ! any fix for this ?
Any idea folks ?
Thanks in advance
Use unicode flag:
If you want to match only arabic you should do:
Update: I see I am apparently wrong about classes not being supported (though the docs at say "Extended properties such as "Greek" or "InMusicalSymbols" are not supported by PCRE" but the comment at http://php.net/manual/en/regexp.reference.unicode.php#102756 says they are supported), so I guess M42's is the better answer. They can, however, be done with ranges as follows: