Php Chinese character to pinyin _ PHP Tutorial

Source: Internet
Author: User
Php Chinese character to pinyin. Php functions for converting Chinese characters to pinyin (modified by the SpGetPinyin function of dedecms (dedecms1_deincinc_fun_funadmin.php). The Dictionary of dedecms is incomplete ):? Phpfunctionpinyin ($ str, $ is php conversion of Chinese characters to pinyin

Php functions (modified by the SpGetPinyin function of dedecms (dedecms/include/inc/inc_fun_funAdmin.php). The Dictionary of dedecms is incomplete ):

 0x80) {$ c = $ str [$ I]. $ str [$ I + 1]; $ I ++; if (isset ($ pinyins [$ c]) {$ restr. = ($ ishead = 0 )? $ Pinyins [$ c]: $ pinyins [$ c] [0];} else {$ restr. = "_" ;}} else if (preg_match ("/[a-z0-9]/I", $ str [$ I]) {$ restr. = $ str [$ I];} else {$ restr. = "_" ;}}return $ restr;} // Test echo pinyin ('su insulation film ', 1 ),'
'; Echo pinyin ('Shu Xiaojia thermal insulation film', 0 ),'
'; Echo pinyin ('parrot', 1 ),'
'; Echo pinyin ('parrot', 0 ),'
'; Echo pinyin ),'
'; Echo pinyin ('Sleeping Fort/inoviswon/myside mattress', 0 ),'
';/* Result: srjgrm shurejiageremo yw yingwu mzb_ynws_mysidecd mianzhibao_yinuoweishen_mysidechuangdian */?>

See the attachment for the contained dictionaries: pinyin.rar/pinyin. dic (gbk)

: Http://files.cnblogs.com/luoyunshu/pinyin.rar

Refer:

Http://www.oschina.net/code/snippet_862384_25415

Modify the dedecms Dictionary by using the SpGetPinyin function of dedecms (dedecms/include/inc/inc_fun_funAdmin.php ):? Php function pinyin ($ str, $ is...

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.