php - Checking keywords in post and find matches -


i can not write code check keywords in news if exist 2 matches 5 keywords. script insert post in new database.

here code check 1 keyword , if exist insert news in database.

$sq = 'select keyword keyword'; $receivekey = mysqli_query($conn,$sq); if(! $receivekey ) {     die('could not load data: ' . mysql_error()); }  while($row = mysqli_fetch_array($receivekey)){     $itemkey[] = $row['keyword']; } //echo '<br>'.$itemkey[1]; foreach( $itemkey $newkey => $value){     echo '<br>'.$value;      //print_r($value); }  mysqli_close($conn);  //select correct xml social media  //read xml , check preference //$content = simeplexml_load_file('facebook.xml'); $xml = simplexml_load_file('facebook.xml'); foreach($xml->tue14apr2015 $entry); foreach($entry->post $new){     $new = strtolower($new);         if (is_array($itemkey))     {         foreach($itemkey $e => $ne){                  $pos = strpos($new, $ne);             if ($pos == true){                  echo '<br>'.$new; 

try using substr_count, so:

$occurrence = 0;  foreach($itemkey $key){     $occurrence += substr_count($news, $key); }  if($occurrence >= 2) {     // insert news in database here } 

this increments amount of occurences each keyword found.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -