PHPackages                             trendsoft/capital - 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. trendsoft/capital

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

trendsoft/capital
=================

金额转中文大写

v0.1.2(5y ago)74.2k↓53.8%2MITPHPCI failing

Since Dec 12Pushed 5y ago2 watchersCompare

[ Source](https://github.com/trendsoft/capital)[ Packagist](https://packagist.org/packages/trendsoft/capital)[ Docs](http://www.trendsoft.org)[ RSS](/packages/trendsoft-capital/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (3)Versions (5)Used By (2)

Capital
=======

[](#capital)

> 金额转中文大写。

[![Build Status](https://camo.githubusercontent.com/bd69dbb5cc9fc11432cffc544d0279e57316cee45c04b54e957db9e5f478b0ef/68747470733a2f2f7472617669732d63692e6f72672f7472656e64736f66742f6361706974616c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/trendsoft/capital)[![Latest Stable Version](https://camo.githubusercontent.com/e7aa8f9f1399a2bc6c2a06bf032399340ca3d084914708a06272b48990efa49d/68747470733a2f2f706f7365722e707567782e6f72672f7472656e64736f66742f6361706974616c2f762f737461626c65)](https://packagist.org/packages/trendsoft/capital)[![Latest Unstable Version](https://camo.githubusercontent.com/baa85819d0cf8f028e889188e4f0aeffc1cb616a2bedb87077e2c6af5925f06d/68747470733a2f2f706f7365722e707567782e6f72672f7472656e64736f66742f6361706974616c2f762f756e737461626c65)](https://packagist.org/packages/trendsoft/capital)[![StyleCI](https://camo.githubusercontent.com/0712a8a28617d46b7aefef6e65dfcb089e75915f53e43abd0f970745047f772a/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131333630363737342f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/113606774)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/73a490be4827e7055a03727253e04df2ea339ef954fd2144e2f331d0632d080b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7472656e64736f66742f6361706974616c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/trendsoft/capital/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/2595cecc937a676a8c40c01d244db2d921986212f0533350f679684ca75fc8ab/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7472656e64736f66742f6361706974616c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/trendsoft/capital/?branch=master)[![Build Status](https://camo.githubusercontent.com/020c6d8482ea39674dc5480f87ab936c1661fd494a466d3c7dea361389d9c438/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7472656e64736f66742f6361706974616c2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/trendsoft/capital/build-status/master)[![License](https://camo.githubusercontent.com/37cbee515893d5477c269b939e945c0428832ff2fcae7edaa985d8a6e9f8a9ea/68747470733a2f2f706f7365722e707567782e6f72672f7472656e64736f66742f6361706974616c2f6c6963656e7365)](https://packagist.org/packages/trendsoft/capital)[![Total Downloads](https://camo.githubusercontent.com/d3c371a5ece9e43402fd70cb2171e8a04b442249d1cccf3faa3fa28c8c20ef41/68747470733a2f2f706f7365722e707567782e6f72672f7472656e64736f66742f6361706974616c2f646f776e6c6f616473)](https://packagist.org/packages/trendsoft/capital)[![Monthly Downloads](https://camo.githubusercontent.com/b88cc50d69862fef037ae506669344b21d48b2aa05a7f8836b0618594b7c7f68/68747470733a2f2f706f7365722e707567782e6f72672f7472656e64736f66742f6361706974616c2f642f6d6f6e74686c79)](https://packagist.org/packages/trendsoft/capital)[![Daily Downloads](https://camo.githubusercontent.com/e5f2a00687fcb015a6b4f9ff37a6319b4f581ee5c8a9c55b3a11e4b05defce07/68747470733a2f2f706f7365722e707567782e6f72672f7472656e64736f66742f6361706974616c2f642f6461696c79)](https://packagist.org/packages/trendsoft/capital)

要求
--

[](#要求)

- PHP &gt;= 7.0
- Composer

安装
--

[](#安装)

```
$ composer require "trendsoft/capital" -vvv
```

使用示例
----

[](#使用示例)

> 如果小数部分是2位以上的，会四舍五入。

```
( new Money( 0.001 ) )->toCapital(); //零元
( new Money( 0.005 ) )->toCapital(); //壹分
( new Money( 0.01 ) )->toCapital(); //壹分
( new Money( 0.10 ) )->toCapital(); //壹角
( new Money( 0.105 ) )->toCapital(); //壹角壹分
( new Money( 0.11 ) )->toCapital(); //壹角壹分
( new Money( 0.15 ) )->toCapital(); //壹角伍分
( new Money( 1.01 ) )->toCapital(); //壹元零壹分
( new Money( 10.01 ) )->toCapital(); //壹拾元零壹分
( new Money( 0.09 ) )->toCapital(); //玖分
( new Money( 1.0 ) )->toCapital(); //壹元
( new Money( 1.1 ) )->toCapital(); //壹元壹角
( new Money( 2.0 ) )->toCapital(); //贰元
( new Money( 2.1 ) )->toCapital(); //贰元壹角
```

算法
--

[](#算法)

### 整数部分

[](#整数部分)

如: 10001000

> 壹仟零佰零拾零万壹仟零佰零拾零元

转换`亿`、`万`、前面的零到后面

> 壹仟零佰零拾万零壹仟零佰零拾零元

去掉`零拾`、`零佰`、`零仟`的单位

> 壹仟零零万零壹仟零零零元

处理`零零`为`零`. `2`次(`拾`、`佰`、`仟`)两次刚好把`零零零`为`零`

> 壹仟零万零壹仟零零元

> 壹仟零万零壹仟零元

处理 `零亿`、`零万`、`零元`的`零`

> 壹仟万零壹仟元

### 小数部分

[](#小数部分)

如: 0.75

`零分`处理为空

`零角`处理

如果有整数部分，转`零角`为`零`

如果没有整数部分，转`零角`为空

### 特殊处理

[](#特殊处理)

如: `0`、`0.00` 直接返回`零元`

Contribution
------------

[](#contribution)

[Contribution Guide](.github/CONTRIBUTING.md)

License
-------

[](#license)

MIT

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

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

Every ~480 days

Total

3

Last Release

2164d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12955801?v=4)[hadi](/maintainers/hu19891110)[@hu19891110](https://github.com/hu19891110)

---

Top Contributors

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

---

Tags

capitalphpsdkamountcapitaltrendsoft

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/trendsoft-capital/health.svg)

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

###  Alternatives

[aws/aws-crt-php

AWS Common Runtime for PHP

423329.7M10](/packages/aws-aws-crt-php)[zumba/amplitude-php

PHP SDK for Amplitude

4110.3M5](/packages/zumba-amplitude-php)[ennnnny/tbk

简约优雅的淘宝客SDK

29416.5k1](/packages/ennnnny-tbk)

PHPackages © 2026

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