0
我想检查字符串是否是给定字符串之一。它看起来像这样。检查字符串是否等于许多给定字符串之一
$string 'test';
// if given string is 'test' function will return false.
function checkIfIsSubstring($string)
{
if (strcmp($string, 'test2'))
return true;
if (strcmp($string, 'test3'))
return true;
if (strcmp($string, 'test4'))
return true;
return false;
}
有没有PHP函数什么会做同样的事情,没有我创建一个新的功能?
是,'in_array'。文档页面中的第一个示例正是您要做的。 – Jon 2014-08-30 16:21:18
你检查的字符串是否总是相同? – DanDotNet 2014-08-30 16:56:39