Rankings are not ideal, there is no way, and then make pseudo-original, who has written a good function to share under????
Synonym table. txt
Domestic-China
...........
Realization, found that the domestic exchange of China, found China for domestic ....
Such as: China's domestic
The result: domestic China
The direct substitution will become China or domestic, not achieve the effect
.
Reply to discussion (solution)
$d = Array ( ' domestic ' = ' China ', ' china ' = ' domestic ',); Echo strtr (' China ', $d);
Domestic China
Moderator Calendar harm, refer to the online add more lines of code, immediately line up
Echo strtr_words (' who returns results devastated-depressed '); function Strtr_words ($str) { $words =array (); $content = file_get_contents (' _web/word.txt ');//thesaurus $content = Str_replace ("\ R", "", $content); Remove line breaks (to be compatible with Linux hosts) $content = Preg_split ('/\n/', $content,-1, preg_split_no_empty);//\n split character foreach ($ Content as $k = = $v) { if ($k!=0) { $str _data = explode ('-', $v);//keyword separator $words +=array ("$str _ Data[0] "=" $str _data[1] "); $words +=array ("$str _data[1]" = "$str _data[0]");//multi-line reverse synonym also replace } } return Strtr ($str, $words); return result}