return $this->result; } public function hot_word($N = "") { $HW = array_count_values($this->result); arsort($HW); if ($N) { $i = 0; foreach ($HW as $key => $val) { if ($i < $N && cstrlen($key) > 1) { $R[] = $key; $i++; } elseif ($i > $N) { break; } } return $R; } return $HW; } } //function cstrlen($str){ // return mb_strlen($str,"gb2312"); //} //function csubstr($str,$length,$suffix=FALSE,$start=0){ // return mb_substr($str, $start, $length, "gb2312"); //} $sw = new SplitWord(); $k = $sw->getWord('“我是一个好宝宝,明天去上学!”', 4); $hw = $sw->hot_word(10); var_dump($k);