文件名称:同义词替换
文件大小:608B
文件格式:PHP
更新时间:2015-05-01 05:23:19
同义词,替换
同意词替换 $content = file_get_contents(ROOT_PATH . 'includes'.'/strtr_words/words.txt');//词库 if(is_gb2312($content)) { $content = iconv('GBK','UTF-8', $content); } $content = str_replace("\r", "",$content); //去掉换行符(以便兼容Linux主机) $content = preg_split('/\n/', $content, -1, PREG_SPLIT_NO_EMPTY);//\n分割字符 foreach($content as $k=>$v) { if($k!=0) { $str_data = explode('→',$v);//关键词分割符 $words+=array($str_data[0]=>$str_data[1]); } }