Rankings are not ideal, there is no way, and then make pseudo-original, who has written a good function to share under

Source: Internet
Author: User
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}
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.