0

I'm working on a web for users in the Middle East. I have added a part that users can write their ideas but I want them to be able to type in Arabic alphabet and not English. what should I do?

At first, I tried this way but it didn't work

if(preg_match('%^[A-Za-z]$%',$userpost))
{ echo 'please write your post in arabic'; 
}else{
 echo 'your post is valid';
}
reza hooshyarr
  • 107
  • 1
  • 5
  • 3
    Possible duplicate of [Regular Expression Arabic characters and numbers only](https://stackoverflow.com/questions/29729391/regular-expression-arabic-characters-and-numbers-only) – Mohammad Oct 21 '18 at 10:03

1 Answers1

0

try this preg_match("~^[a-z\-'\s\p{Arabic}]{1,60}$~iu", $userpost)

Skora
  • 107
  • 11
  • Thank you for this code snippet, which might provide some limited, immediate help. A [proper explanation would greatly improve its long-term value](//meta.stackexchange.com/q/114762/206345) by showing _why_ this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please [edit] your answer to add some explanation, including the assumptions you've made. – Blue Oct 21 '18 at 16:07