亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    php怎么實(shí)現(xiàn)漢語轉(zhuǎn)拼音

    php實(shí)現(xiàn)漢語轉(zhuǎn)拼音的方法:1、安裝“overtrue/pinyin”拓展;2、通過“$pinyin = new Pinyin();$pinyin->permalink('測試漢字轉(zhuǎn)拼音');”等方式進(jìn)行轉(zhuǎn)換即可。

    php怎么實(shí)現(xiàn)漢語轉(zhuǎn)拼音

    本文操作環(huán)境:Windows7系統(tǒng)、PHP7.1版,DELL G3電腦

    php怎么實(shí)現(xiàn)漢語轉(zhuǎn)拼音?

    php 實(shí)現(xiàn) 漢字轉(zhuǎn)拼音

    php漢字轉(zhuǎn)拼音我使用到了overtrue/pinyin拓展

    一:安裝overtrue/pinyin拓展

    composer require overtrue/pinyin

    overtrue/pinyin拓展GitHub地址:https://github.com/overtrue/p…

    二:overtrue/pinyin拓展簡單使用

    overtrue/pinyin拼音轉(zhuǎn)成拼音常見的轉(zhuǎn)化方式:

    PINYIN_TONE   #帶音調(diào)的轉(zhuǎn)化方式 PINYIN_KEEP_NUMBER  #保留數(shù)字的轉(zhuǎn)化方式 PINYIN_KEEP_ENGLISH#保留英文的轉(zhuǎn)化方式 PINYIN_KEEP_PUNCTUATION#保留標(biāo)點(diǎn)的轉(zhuǎn)化方式 PINYIN_UMLAUT_V#使用 v 代替 yu的轉(zhuǎn)化方式

    1:漢字轉(zhuǎn)成拼音數(shù)組

    (1):漢字轉(zhuǎn)成無無音調(diào)的拼音

    $pinyin = new Pinyin(); $pinyin->convert('測試漢字轉(zhuǎn)拼音');

    輸出數(shù)據(jù)為:

    ['ce', 'shi', 'han', 'zi', 'zhuan', 'pin', 'yin']

    (2):漢字轉(zhuǎn)成帶音調(diào)的拼音

    $pinyin = new Pinyin(); $pinyin->convert('測試漢字轉(zhuǎn)拼音', PINYIN_TONE);

    輸出數(shù)據(jù)為:

    ['cè', 'shì', 'hàn', 'zì', 'zhuǎn', 'pīn', 'yīn']

    (3):漢字轉(zhuǎn)拼音中l(wèi)v拼音為lyu,使用此方法使用 v 代替 yu

    $pinyin = new Pinyin(); $pinyin->convert('呂氏春秋'); $pinyin->convert('呂氏春秋', PINYIN_UMLAUT_V);

    第一個方法輸出為:

    ['lyu', 'shi', 'chun', 'qiu']

    第二個方法輸出為:

    ['lv', 'shi', 'chun', 'qiu']

    2:漢字轉(zhuǎn)成拼音字符串

    $pinyin = new Pinyin(); $pinyin->permalink('測試漢字轉(zhuǎn)拼音'); $pinyin->permalink('測試漢字轉(zhuǎn)拼音', '.');

    第一個方法輸出為:

    ce-shi-han-zi-zhuan-pin-yin

    第二個方法輸出為:

    ce.shi.han.zi.zhuan.pin.yi

    3:漢字轉(zhuǎn)成首字母字符串

    $pinyin = new Pinyin(); $pinyin->abbr('測試漢字轉(zhuǎn)拼音'); $pinyin->abbr('測試漢字轉(zhuǎn)拼音', '-');

    第一個方法輸出為:

    cshzzpy

    第二個方法輸出為:

    c-s-h-z-z-p-y

    4:整段漢字(帶標(biāo)點(diǎn)符號)轉(zhuǎn)成拼音

    $pinyin = new Pinyin(); $pinyin->sentence('測試漢字轉(zhuǎn)拼音,這是測試!!!'); $pinyin->sentence('測試漢字轉(zhuǎn)拼音,這是測試!!!', '-');

    第一個方法輸出為:

    ce shi han zi zhuan pin yin, zhe shi ce shi!!!

    第二個方法輸出為:

    ce-shi-han-zi-zhuan-pin-yin,-zhe-shi-ce-shi!!!

    5:姓名漢字轉(zhuǎn)拼音,有些漢字常見讀音和作為姓名讀音不同,例如仇,常見讀音為chou,但是作為姓氏時都qiu

    $pinyin = new Pinyin(); $pinyin->name('仇某某');

    輸出結(jié)果為:

    ['qiu', 'mou', 'mou']

    推薦學(xué)習(xí):《PHP視頻教程》

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號