<?phpecho strtr_words('這里是需要轉(zhuǎn)換的文字');function strtr_words($str){ $words=array(); $content = file_get_contents('word.txt');//詞庫(kù) $content = str_replace( '\r', '',$content); //去掉換行符(以便兼容Linux主機(jī)) $content = preg_split('/\n/', $content, -1, PREG_SPLIT_NO_EMPTY);//\n分割字符 foreach($content as $k=>$v) { if($k!=0) { $str_data = explode('→',$v);//關(guān)鍵詞分割符 $words =array('$str_data[0]'=>'$str_data[1]'); } } return strtr($str,$words);//返回結(jié)果}?>
詞庫(kù)可以去百度搜索下載
格式為
好看→美麗
難過→傷心
我的影視站:好看影視網(wǎng)
聯(lián)系客服