所以我有下面的代码,但我想知道如何判断'$ text'是否包含'所有者'这些字。我该怎么做呢?我环顾四周,但我找不到任何东西。如何检查一组字是否在字符串中与PHP
foreach($anchors as $a) {
$i = $i + 1;
$text = $a->nodeValue;
$href = $a->getAttribute('href');
if ($i > 22 && $i < 64 && ($i % 2) == 0) {
//if ($i<80) {
echo "<a href =' ".$href." '>".$text."</a><br/>";
}
// }
//$str = file_get_contents($href);
//$result = (substr_count(strip_tags($str),"ipod"));
//echo ($result);
}
你只是想检查是否'$ text' “由所有者” 有子''?原因http://www.php.net/manual/en/function.strstr.php会这样做...如果你需要不区分大小写,请使用http://www.php.net/manual/en/function.stristr .php。和http://www.php.net/manual/en/function.preg-match.php将允许您使用正则表达式来匹配变量间距,确切的单词等。 – FrankieTheKneeMan 2013-04-20 00:12:59