0

以下にこのコードを示しますが、「$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);
}
4

1 に答える 1

1

何かのようなもの:

$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";
}
于 2013-04-20T01:06:59.010 に答える