I have sentence, I wanna split into words, and then check them with the data in stopword table. I wanna count the number of same data (total). but, total doesn’t give me the total of same data. How to sum the data I need ? thanks
$word ='temporal. the text mining in a evolutionary a theme patterns theme threads clustering';
$symbol = array(".", ",", "\\", "-", "\"", "(", ")", "<", ">", "?", ";", ":", "+", "%", "\r", "\t", "\0", "\x0B");
$cleanMeta = str_replace($symbol, " ", $word);
$key = strtolower($cleanMeta);
$key = explode(" ", trim($key));
foreach($key as $word_key){
$query = mysql_query ("SELECT COUNT(stoplist_word) AS total FROM tb_stopword WHERE stoplist_word = '$word_key'");
while ($row = mysql_fetch_array($query)) {
$row1 = $row['total'];
echo $row1;
}
}
considering you already cleaned the input string, you dont need a foreach with a new query for every word. You could do:
if you realy want the foreach use: