PHPackages                             haoke/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. haoke/pinyin

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

haoke/pinyin
============

这是对github源地址 gitsher/pinyin 的composer封装

01PHP

Since Mar 7Pushed 5y agoCompare

[ Source](https://github.com/haoke12138/pinyin)[ Packagist](https://packagist.org/packages/haoke/pinyin)[ RSS](/packages/haoke-pinyin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

汉字转拼音
=====

[](#汉字转拼音)

PHP版汉字拼音（字符串包含数字、拼音、多音字、首字母等）
-----------------------------

[](#php版汉字拼音字符串包含数字拼音多音字首字母等)

### 简单转换

[](#简单转换)

> Pinyin\_Pinyin::convertPinyin('UTF8-PHP版汉字转拼音');

> UTF8-PHPbanhanzizhuanpinyin

### 简单转换，自定义连接符

[](#简单转换自定义连接符)

> Pinyin\_Pinyin::convertPinyin('UTF8-PHP版汉字转拼音', '\_');

> U\_T\_F\_8\_-\_P\_H\_P\_ban\_han\_zi\_zhuan\_pin\_yin

### 首字母转换

[](#首字母转换)

> Pinyin\_Pinyin::convertInitalPinyin('UTF8-PHP版汉字转拼音'); UTF8-PHPbhzzpy

### 多音字

[](#多音字)

> Pinyin\_Pinyin::convertPinyinList('UTF8-PHP版汉字转拼音多音字-圈');

> array(
> 'UTF8-PHPbanhanzizhuanpinyinduoyinzi-quan',
> 'UTF8-PHPbanhanzizhuanpinyinduoyinzi-juan',
> 'UTF8-PHPbanhanzizhuanpinyinduoyinzi-juan',
> );

### 多音字首字母

[](#多音字首字母)

> Pinyin\_Pinyin::convertInitalPinyinList('UTF8-PHP版汉字转拼音多音字-圈');

> array(
> 'UTF8-PHPbhzzpydyz-q',
> 'UTF8-PHPbhzzpydyz-j',
> 'UTF8-PHPbhzzpydyz-j',
> );

### 所有转换结果

[](#所有转换结果)

> Pinyin\_Pinyin::convertAllPinyinList('UTF8-PHP版汉字转拼音多音字-圈');

> array (
> 'full' =&gt;
> array (
> 'UTF8-PHPbanhanzizhuanpinyinduoyinzi-quan',
> 'UTF8-PHPbanhanzizhuanpinyinduoyinzi-juan',
> 'UTF8-PHPbanhanzizhuanpinyinduoyinzi-juan',
> ), 'initial' =&gt;
> array (
> 'UTF8-PHPbhzzpydyz-q',
> 'UTF8-PHPbhzzpydyz-j',
> 'UTF8-PHPbhzzpydyz-j',
> ),

更新
--

[](#更新)

1. 拆解了复杂大方法为多个简单方法；
2. 修复单个汉字或汉字开头转换异常；
3. 去重结果中重复结果
4. 清理冗余判断；
5. 增加自定义分隔符；
6. 增加 Demo 文件；

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0488325a2f50985c4b7252540b24d6bece60f99339d5bf46b2499d80213714e1?d=identicon)[浩克](/maintainers/%E6%B5%A9%E5%85%8B)

---

Top Contributors

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

### Embed Badge

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

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

PHPackages © 2026

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