如何查看给定字符串是否包含我要查找的多个字符?例如:
$manywords = "apple orange pineapple banana cat";
if (!(strstr($manywords, 'apple'||'cat')))
{
echo "either word found";
}
有没有一种方法可以使用strstr
函数而不必像下面这样写两次:
if (!((strstr($manywords, 'apple')||(strstr($manywords, 'cat')))
{
echo "either word found";
}
$did_it_match = preg_match('/apple|cat/',$manywords);