Reputation: 1372
How can I write this in PHP?
if ($text contains at least one letter from A to Z, regardless of numbers or other characters)
echo 'Yes';
else
echo 'No';
Please help.
Upvotes: 0
Views: 2713
Reputation: 5082
Use preg_match() function
if (preg_match('/[a-z]/i', $text))
echo "Matches";
else
echo "No matches";
Upvotes: 5
Reputation: 317
Like this
if (preg_match('/[A-Za-z]/i', $variable)) {
echo 'Yes';
}
else {
echo 'No';
}
Upvotes: 5
Reputation: 9322
Here's something that will help
preg_match("/[a-z]/i",$text);
Upvotes: 5