Skip to main content
edited tags
Link
Eduard Luca
  • 6.6k
  • 18
  • 87
  • 140
Source Link

How do I check if a certain set of words is in a string with PHP

So I have this code below but I am wondering how I can tell if '$text' contains the words 'by owner'. How do I do this? I looked around but I can't find anything.

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);
}