ZhuyinPinyin
1.0.0
A PHP library that deals with Zhuyin (注音) to Pinyin (漢語拼音), Pinyin to Zhuyin.
https://github.com/localvar/zhuyin (Golang version)
The original idea is from a Golang library written by Bomin Zhang, I recoding it with PHP and using on DictPedia project.
For example, this library will translate zhang1 to zhāng (pinyin) or ㄓㄤ (zhuyin), zhāng or ㄓㄤ decode to zhang1, and also support pinyin to zhuyin and zhuyin to pinyin.
這個函式庫的原始邏輯設計出自以 Golang 編寫,因為本人需要用在字典百科專案中,但尋無以 PHP 版本實現的注音轉拼音、拼音轉注音的函式庫,所以我把它從 Golang 改寫成 PHP 版本。
composer require dictpedia/zhuyin-pinyin
$zh = new DictPediaZhuyinPinyin();
Resutn empty string if the input string is invaild.
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
MIT
https://packagist.org/packages/dictpedia/zhuyin-pinyin