Php Chinese to pinyin can be converted to only the first letter, or utf8, gbk

Source: Internet
Author: User
Php Chinese to pinyin can be converted to only the first letter, or utf8, gbk & lt ;? Php /************************************** * *********************************** php conversion pinyin can only be the first letter, you can also set utf8 and gbk
 = '5. 0 ')? Array_combine ($ _ TDataKey, $ _ TDataValue): _ Array_Combine ($ _ TDataKey, $ _ TDataValue); arsort ($ _ Data); reset ($ _ Data ); if ($ _ Code! = 'Gb2312') $ _ String = _ U2_Utf8_Gb ($ _ String); $ _ Res = ''; for ($ I = 0; $ I
 
  
160) {$ _ Q = ord (substr ($ _ String, ++ $ I, 1 )); $ _ P = $ _ P * 256 + $ _ Q-65536;} $ _ Res. = _ Pinyin ($ _ P, $ _ Data, $ isInitial);} return preg_replace ("/[^ a-z0-9] */", '', $ _ Res );} function _ Pinyin ($ _ Num, $ _ Data, $ isInitial) {if ($ _ Num> 0 & $ _ Num <160) return chr ($ _ Num ); elseif ($ _ Num <-20319 | $ _ Num>-10247) return ''; else {foreach ($ _ Data as $ k => $ v) {if ($ v <= $ _ Num) break;} if ($ isInitial) $ k = substr ($ k ); // whether to show only the first write return $ k;} function _ U2_Utf8_Gb ($ _ C) {$ _ String = ''; if ($ _ C <0x80) $ _ String. = $ _ C; elseif ($ _ C <0x800) {$ _ String. = chr (0xC0 | $ _ C> 6); $ _ String. = chr (0x80 | $ _ C & 0x3F);} elseif ($ _ C <0x10000) {$ _ String. = chr (0xE0 | $ _ C> 12); $ _ String. = chr (0x80 | $ _ C> 6 & 0x3F); $ _ String. = chr (0x80 | $ _ C & 0x3F);} elseif ($ _ C <0x200000) {$ _ String. = chr (0xF0 | $ _ C> 18); $ _ String. = chr (0x80 | $ _ C> 12 & 0x3F); $ _ String. = chr (0x80 | $ _ C> 6 & 0x3F); $ _ String. = chr (0x80 | $ _ C & 0x3F);} return iconv ('utf-8', 'gb2312 ', $ _ String );} function _ Array_Combine ($ _ Arr1, $ _ Arr2) {for ($ I = 0; $ I
  
 
?

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.