我想知道如果变量只包含1个字,我怎么能在PHP中找到.它应该能够识别:"foo""1326""; 394aa"等.
它会是这样的:
$txt = "oneword";
if($txt == 1 word){ do.this; }else{ do.that; }
Run Code Online (Sandbox Code Playgroud)
谢谢.
我假设一个单词被定义为由一个空格符号分隔的任何字符串
$txt = "multiple words";
if(strpos(trim($txt), ' ') !== false)
{
// multiple words
}
else
{
// one word
}
Run Code Online (Sandbox Code Playgroud)