PHP code example of asika32764 / pinyin

1. Go to this page and download the library: Download asika32764/pinyin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

asika32764 / pinyin example snippets


string THL\Pinyin::bpmf(string $source)

// returns "THL ㄊㄞˊ ㄨㄢ ㄏㄨㄚˊ ㄩˇ ㄌㄨㄛˊ ㄇㄚˇ ㄆㄧㄣ ㄧㄣ"
$output = THL\Pinyin::bpmf("THL台灣華語羅馬拼音");

string THL\Pinyin::pinyin(string $source, array $options)

// returns "THL tai2 wan1 hua2 yu3 luo2 ma3 pin1 yin1"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音");

// returns "THL taíwan huáyǔ luómǎ pinyin"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音", array('tone' => 'mark', 'split' => 'phrase'));

// returns "THL t'ai wan hua yü lo ma p'in yin"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音", array('notation' => 'wg', 'tone' => 'none', 'split' => 'word'));

string THL\Pinyin::slug(string $source, array $options)

// returns "thl-tai-wan-hua-yu-luo-ma-pin-yin"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音");

// returns "thl-taiwan-huayu-luoma-pinyin"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音", array('split' => 'phrase'));

// returns "thl-tai2wan1-hua2yu3-luo2ma3-pin1yin1"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音", array('notation' => 'ty', 'tone' => 'number', 'split' => 'phrase'));