PHP: Allow Letters, Numbers and Arabic Character

How can I resolve the Arabic character in preg_match?

if(!preg_match("/^[a-zA-Z0-9]+$/", "لحمدلله")) {
    echo "Firstname can only use letters, numbers and arabic characters.";
}

      

+3
php arabic


source to share


1 answer


you can use this:



if(!preg_match("/^[\p{Arabic}a-zA-Z0-9]+$/u", "لحمدلله")) {
    echo "Firstname can only use letters, numbers and arabic characters.";
}

      

+3


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics