PHP: 允许字母、数字和阿拉伯字符

PHP: Allow letters, numbers and arabic character

如何在 preg_match 中允许使用阿拉伯字符?

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

你可以使用这个:

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