时间:2021-07-01 10:21:17 帮助过:2人阅读
$title='我从未见过奥特曼'; $len= mb_strlen($title,'utf-8'); $l=0; while($l<$len-1){ $arr[]=mb_substr($title,$l,2,'UTF-8'); $l++; } echo join('|',$arr);
------解决方案--------------------
你可以安装SCWS中文分词系统,有Windows和linux两种版本,可作为php的扩展使用。安装后,用phpinfo查看,如果出现scws,则代表成功。
例子:
$sh = scws_open();
scws_set_charset($sh, 'gbk');
scws_set_multi($sh,SCWS_MULTI_SHORT | SCWS_MULTI_DUALITY | SCWS_MULTI_ZMAIN | SCWS_MULTI_ZALL);
$text = "我从未见过奥特曼";
scws_send_text($sh, $text);
$top = scws_get_tops($sh, 10);
print_r($top);