PHP code example of dictpedia / zhuyin-pinyin

1. Go to this page and download the library: Download dictpedia/zhuyin-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/ */

    

dictpedia / zhuyin-pinyin example snippets


$zh = new \DictPedia\ZhuyinPinyin();

echo $zh->encodePinyin('zhang1');

// result: zhāng

echo $zh->decodePinyin('zhāng');

// result: zhang1

echo $zh->encodeZhuyin('zhang1');

// result: ㄓㄤ

echo $zh->decodeZhuyin('ㄓㄤ');

// result: zhang1

echo $zh->pinyinToZhuyin('zhāng');

// result: ㄓㄤ

echo $zh->zhuyinToPinyin('ㄓㄤ');

// result: zhāng