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


so have code below wondering how can tell if '$text' contains words 'by owner'. how do this? looked around can't find anything.

foreach($anchors $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); } 

something like:

$text = $a->nodevalue; if(strpos($text, "by owner") == -1){  // if want text *start* "by owner", can replace strpos($text, "by owner") != 0     echo "doesn't have owner"; } else{     echo "has owner"; } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -