php - Function for Finding and counting Trends, similar to twitter -


the results of function saves in sql database twice. how function place keywords in database once?

for example function prints out : array ( [0] => nope# [1] => nope# ) array ( [0] => nope# [1] => nope# )

im not sure why results returning twice?

im student trying self teach, please help!

code example:

function gettrends($text) {     $subject = $text;     $pattern ='/(\w+#)/ui';     $d = date("y-m-d h:i:s"); // year - month - day     preg_match($pattern, $subject, $matches);      $findings = count($matches);      foreach($matches $k=>$value)     {         $insert_trends_query = mysql_query("insert trends set keyword= '$value', occurrence='$findings', date_time='$d' ");         print_r($matches);     } } 


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -