How can I check if the text contains at least one A to Z letter?
How can I write this in PHP?
if ($text contains 开发者_如何学Pythonat least one letter from A to Z, regardless of numbers or other characters)
echo 'Yes';
else
echo 'No';
Please help.
Here's something that will help
preg_match("/[a-z]/i",$text);
Like this
if (preg_match('/[A-Za-z]/i', $variable)) {
echo 'Yes';
}
else {
echo 'No';
}
Use preg_match() function
if (preg_match('/[a-z]/i', $text))
echo "Matches";
else
echo "No matches";
精彩评论