我有一句話,我想分成詞,然後在停用詞表中的數據進行檢查。我想統計相同數據的數量(總數)。但總計不會給我相同數據的總數。如何總結我需要的數據?感謝計算與數據字的相同數據表中的
$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;
}
}
你的得到,如果'的var_dump($鍵)foreach'過嗎? – GBD
@GBD'array(14){[0] => string(8)「temporal」[1] => string(0)「」[2] => string(4)「text」[3] => string (6)「mining」[4] => string(2)「in」[5] => string(12)「evolutionary」[6] => string(1)「a」[7] => string(5) )「theme」[8] => string(8)「patterns」[9] => string(0)「」[10] => string(5)「theme」[11] => string(7) 「[12] => string(0)」「[13] => string(10)」clustering「}' –
對於每個關鍵字,你沒有得到'total' – GBD