如何在PHP中编写此代码?如何检查文字是否至少包含一个A到Z字母?
if ($text contains at least one letter from A to Z, regardless of numbers or other characters)
echo 'Yes';
else
echo 'No';
请帮忙。
如何在PHP中编写此代码?如何检查文字是否至少包含一个A到Z字母?
if ($text contains at least one letter from A to Z, regardless of numbers or other characters)
echo 'Yes';
else
echo 'No';
请帮忙。
这里的东西,这将有助于
preg_match("/[a-z]/i",$text);
像这样
if (preg_match('/[A-Za-z]/i', $variable)) {
echo 'Yes';
}
else {
echo 'No';
}
使用的preg_match()函数
if (preg_match('/[a-z]/i', $text))
echo "Matches";
else
echo "No matches";
的preg_match()参见手册的例子。 – 2011-09-26 03:12:11
我不知道。我不想用字母排列并检查。这似乎不是一个理想的解决方案。 – oaziz