Reputation: 19651
How can i Match arabic letters with regexp in php
My Code
$name = $_GET("name");
if (arabic letters only and spaces) // using regexp
Upvotes: 4
Views: 7280
Reputation: 138
I am using PHP version 7.3.33 and the following solution worked for me.
if(preg_match("/^[\x{0621}-\x{064A} ]+$/u", $name])) {
echo 'Yes, it contains Arabic letters only and spaces';
}
Upvotes: -1
Reputation: 9489
I think your answer is here: Check the language of string based on glyphs in PHP
if(preg_match("/\p{Arabic}/u", $name])) {
echo 'valid';
}
Upvotes: 10