PHPackages                             dictpedia/zhuyin-pinyin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dictpedia/zhuyin-pinyin

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dictpedia/zhuyin-pinyin
=======================

A PHP library that deals with Zhuyin to Pinyin and Pinyin to Zhuyin.

1.0(9y ago)73093[1 issues](https://github.com/DictPedia/ZhuyinPinyin/issues)MITPHPPHP &gt;=5.3.9

Since Mar 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/DictPedia/ZhuyinPinyin)[ Packagist](https://packagist.org/packages/dictpedia/zhuyin-pinyin)[ Docs](https://github.com/DictPedia/ZhuyinPinyin)[ RSS](/packages/dictpedia-zhuyin-pinyin/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

ZhuyinPinyin
============

[](#zhuyinpinyin)

A PHP library that deals with Zhuyin (注音) to Pinyin (漢語拼音), Pinyin to 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](https://en.dictpedia.org).

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 編寫，因為本人需要用在[字典百科](https://zh.dictpedia.org)專案中，但尋無以 PHP 版本實現的注音轉拼音、拼音轉注音的函式庫，所以我把它從 Golang 改寫成 PHP 版本。

- 此PHP 版與 Golang 原版的差別是捨棄字串陣列，分別讀取個別字元進去陣列以避免可能的 UTF-8字元問題
- 原始邏輯已經處理的很好了，所以直接移植為 PHP 版本。只加了一個函式 splitString 來處理個別 UTF-8 字元

Install
-------

[](#install)

```
composer require dictpedia/zhuyin-pinyin

```

Usage
-----

[](#usage)

```
$zh = new \DictPedia\ZhuyinPinyin();
```

Resutn empty string if the input string is invaild.

API
---

[](#api)

### encodePinyin

[](#encodepinyin)

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

// result: zhāng
```

### decodePinyin

[](#decodepinyin)

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

// result: zhang1
```

### encodeZhuyin

[](#encodezhuyin)

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

// result: ㄓㄤ
```

### decodeZhuyin

[](#decodezhuyin)

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

// result: zhang1
```

### pinyinToZhuyin

[](#pinyintozhuyin)

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

// result: ㄓㄤ
```

### zhuyinToPinyin

[](#zhuyintopinyin)

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

// result: zhāng
```

License
-------

[](#license)

MIT

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3349d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fca418a834057a4203c6856e316ca4d7c71fa1b9076977e08e5c4d5a9cc9aec6?d=identicon)[terrylinooo](/maintainers/terrylinooo)

---

Top Contributors

[![terrylinooo](https://avatars.githubusercontent.com/u/11989371?v=4)](https://github.com/terrylinooo "terrylinooo (15 commits)")

---

Tags

chinese-charactersphp-librarypinyinzhuyinphpPinyinChinesezhuyin

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dictpedia-zhuyin-pinyin/health.svg)

```
[![Health](https://phpackages.com/badges/dictpedia-zhuyin-pinyin/health.svg)](https://phpackages.com/packages/dictpedia-zhuyin-pinyin)
```

###  Alternatives

[overtrue/pinyin

Chinese to pinyin translator.

4.5k6.5M72](/packages/overtrue-pinyin)[wilon/php-number2chinese

PHP数字转为汉字描述、人民币大写方法。

14632.0k1](/packages/wilon-php-number2chinese)[thl/pinyin

Romanization tool for Traditional Chinese

2519.1k](/packages/thl-pinyin)[xiaodi/think-pinyin

ThinkPHP 中文转拼音扩展包

344.6k](/packages/xiaodi-think-pinyin)[lokielse/laravel-pinyin

Chinese Pinyin Bundle For Laravel

1613.6k](/packages/lokielse-laravel-pinyin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
