I have this block of code
public function onlyLetters($string) {
if(preg_match("/[a-zA-Z]/", $string)) {
return true;
} else {
return false;
}
}
but it always returns false, what would the reason be?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your string most likely doesn’t contain what you expect, and doesn’t have a single upper or lower case a-z letter.
OR – you aren’t handling the return value correctly
If you check these assumptions, you’ll probably solve it yourself 🙂