所以我下面有这个代码,但我想知道我怎么能告诉'$text'是否包含'by owner'这个词。我该怎么做呢?我四处看了看,但什么也没找到。
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 = $a->nodeValue;
if(strpos($text, "by owner") == -1){ // if you want the text to *start* with "by owner", you can replace this with strpos($text, "by owner") != 0
echo "Doesn't have by owner";
}
else{
echo "Has by owner";
}