1
下表顯示字符串$commentstring
中的所有單詞。我如何排除某些文章,介詞和動詞,如「是,是,是」?排除數組中的某些字
$words = explode(" ", $commentstring);
$result = array();
arsort($words);
foreach($words as $word) {
if(!is_numeric($word)){
$result[$word]++;
arsort($result);
}
}
echo "<table>";
foreach($result as $word => $count1) {
echo '<tr>';
echo '<td>';
echo "$word";
echo '</td>';
echo '<td>';
echo "$count1 ";
echo '</td>';
echo '</tr>';
}
echo "</table>";
preg_replace怎麼樣? – ngen 2012-02-04 01:45:49
http://stackoverflow.com/q/1728727/212218可能的重複 – 2012-02-04 01:50:58