PHPackages                             phpviet/number-to-words - 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. phpviet/number-to-words

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

phpviet/number-to-words
=======================

Thư viện hổ trợ chuyển đổi số sang chữ số.

1.3.0(4y ago)219.1k↑91.7%12[1 issues](https://github.com/phpviet/number-to-words/issues)5MITPHPPHP &gt;=7.1CI failing

Since Jun 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/phpviet/number-to-words)[ Packagist](https://packagist.org/packages/phpviet/number-to-words)[ Docs](https://github.com/phpviet/number-to-words)[ RSS](/packages/phpviet-number-to-words/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (11)Used By (5)

 [ ![](https://avatars0.githubusercontent.com/u/50674062) ](https://github.com/phpviet)

Number To Words
===============

[](#number-to-words)

 [![Latest version](https://camo.githubusercontent.com/4538b8578ef89af43613c66dcb2f391cb31d136c66c27d3020d4cfa2092d7c8b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706870766965742f6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/number-to-words) [![Build status](https://camo.githubusercontent.com/7cd8e3e504c79203689df90c5ee32ca5ac7f6ff753d5fa011ad7de1723a2d9ef/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f706870766965742f6e756d6265722d746f2d776f7264732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/phpviet/number-to-words) [![Quantity score](https://camo.githubusercontent.com/31be999eddd4e32376bf2a1dce7e40a9e44f45bfb5d4df8e376a9a6aa54d2516/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f706870766965742f6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/phpviet/number-to-words) [![StyleCI](https://camo.githubusercontent.com/ae0ab1f6142240fb0682b84da8922440efe719b838df4ada77119c8187249b57/68747470733a2f2f7374796c6563692e696f2f7265706f732f3138393433393134392f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/189439149) [![Total download](https://camo.githubusercontent.com/6d48f93f4b25131a78bd08b419cb50d159a7ab27a990d934b29b7ba210c6e87e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706870766965742f6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/number-to-words) [![License](https://camo.githubusercontent.com/7387244b5428516fc83bd0daa039946c4eb89f458fdb4c7846b792fcd1a6ef40/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f706870766965742f6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/number-to-words)

Thông tin
---------

[](#thông-tin)

Thư viện hổ trợ chuyển đổi số sang chữ số Tiếng Việt.

Cài đặt
-------

[](#cài-đặt)

Cài đặt Number To Words thông qua [Composer](https://getcomposer.org):

```
composer require phpviet/number-to-words
```

Cách sử dụng
------------

[](#cách-sử-dụng)

### Tích hợp sẵn trên các framework phổ biến hiện tại

[](#tích-hợp-sẵn-trên-các-framework-phổ-biến-hiện-tại)

- [`Laravel`](https://github.com/phpviet/laravel-number-to-words)
- [`Symfony`](https://github.com/phpviet/symfony-number-to-words)
- [`Yii`](https://github.com/phpviet/yii-number-to-words)

hoặc nếu bạn muốn sử dụng không dựa trên framework thì tiếp tục xem tiếp.

### Các tính năng của thư viện:

[](#các-tính-năng-của-thư-viện)

- [`Chuyển đổi số sang chữ số`](#Chuy%E1%BB%83n-%C4%91%E1%BB%95i-s%E1%BB%91-sang-ch%E1%BB%AF-s%E1%BB%91)
- [`Chuyển đổi số sang tiền tệ`](#Chuy%E1%BB%83n-%C4%91%E1%BB%95i-s%E1%BB%91-sang-ti%E1%BB%81n-t%E1%BB%87)
- [`Thay cách đọc số`](#Thay-c%C3%A1ch-%C4%91%E1%BB%8Dc-s%E1%BB%91)

### Chuyển đổi số sang chữ số

[](#chuyển-đổi-số-sang-chữ-số)

Thư viện cung cấp cho chúng ta lớp `PHPViet\NumberToWords\Transformer` để thực hiện việc chuyển đổi thông qua phương thức `toWords` của đối tượng:

```
use PHPViet\NumberToWords\Transformer;

$transformer = new Transformer();

// âm năm
$transformer->toWords(-5);

// năm
$transformer->toWords(5);

// năm phẩy năm
$transformer->toWords(5.5);

// mười lăm
$transformer->toWords(15);

// một trăm linh năm
$transformer->toWords(105);

// bốn
$transformer->toWords(4);

// mười bốn
$transformer->toWords(14);

// hai mươi tư
$transformer->toWords(24);

// một trăm ba mươi tư
$transformer->toWords(134);

// một
$transformer->toWords(1); // một

// mười một
$transformer->toWords(11);

// hai mươi mốt
$transformer->toWords(21);

 // một trăm nghìn không trăm hai mươi mốt.
$transformer->toWords(100021);

// một trăm ba mươi mốt triệu không trăm năm mươi nghìn không trăm ba mươi lăm
$transformer->toWords(131050035);
```

### Chuyển đổi số sang tiền tệ

[](#chuyển-đổi-số-sang-tiền-tệ)

Cũng như cách sử dụng của chuyển số sang chữ số ta cũng sử dụng lớp `PHPViet\NumberToWords\Transformer`để thực thi tác vụ:

```
use PHPViet\NumberToWords\Transformer;

$transformer = new Transformer();

// năm triệu sáu trăm chín mươi nghìn bảy trăm đồng
$transformer->toCurrency(5690700);

// chín mươi lăm triệu năm trăm nghìn hai trăm đồng
$transformer->toCurrency(95500200);

// tám trăm năm mươi tư triệu chín trăm đồng
$transformer->toCurrency(854000900);
```

Trong một số loại tiền tệ, bạn cần thay đổi cách đọc theo đơn vị quy đổi, ví dụ 1 đô = 100 xen

```
use PHPViet\NumberToWords\Transformer;

// Đặt số chữ số phần thập phân (tham số đầu tiên Dictionary có thể null)
$transformer = new Transformer(null, 2);

// năm mươi sáu đô chín mươi xen, thay vì năm mươi sáu đô chín xen
$transformer->toCurrency(56.90);
```

Ngoài ra ta còn có thể sử dụng đơn vị tiền tệ khác thông qua tham trị thứ 2 của phương thức `toCurrency`, với mảng phần từ đầu tiên là đơn vị cho số nguyên và kế tiếp là đơn vị của phân số:

```
use PHPViet\NumberToWords\Transformer;

$transformer = new Transformer();

// sáu nghìn bảy trăm bốn mươi hai đô bảy xen
$transformer->toCurrency(6742.7, ['đô', 'xen']);

// chín nghìn bốn trăm chín mươi hai đô mười lăm xen
$transformer->toCurrency(9492.15, ['đô', 'xen']);

// tám nghìn ba trăm sáu mươi mốt đô bốn xen
$transformer->toCurrency('8361.40', ['đô', 'xen']);
```

### Thay cách đọc số

[](#thay-cách-đọc-số)

Trong thư viện ngoài cách đọc tiêu chuẩn còn hổ trợ cho chúng ta lớp `PHPViet\NumberToWords\SouthDictionary`giúp đọc số theo phong cách trong Nam:

```
use PHPViet\NumberToWords\Transformer;
use PHPViet\NumberToWords\SouthDictionary;

$transformer = new Transformer();
$southDictionary = new SouthDictionary();
$southTransformer = new Transformer($southDictionary);

$transformer->toWords(101); // một trăm linh một
$southTransformer->toWords(101); // một trăm lẻ một

$transformer->toWords(1000); // một nghìn
$southTransformer->toWords(1000); // một ngàn

$transformer->toWords(24) // hai mươi tư
$southTransformer->toWords(24); // hai mươi bốn

$transformer->toCurrency(124001); // một trăm hai mươi tư nghìn không trăm linh một
$southTransformer->toCurrency(124001); // một trăm hai mươi bốn ngàn không trăm lẻ một
```

Nếu như bạn muốn thay đổi cách đọc theo ý bạn thì hãy tạo một lớp `Dictionary` kế thừa `PHPViet\NumberToWords\Dictionary` hoặc thực thi mẫu trừu tượng `PHPViet\NumberToWords\DictionaryInterface`:

```
use PHPViet\NumberToWords\Dictionary;
use PHPViet\NumberToWords\Transformer;

class MyDictionary extends Dictionary {

    /**
     * @inheritDoc
     */
    public function specialTripletUnitFive(): string
    {
        return 'nhăm';
    }

}

$transformer = new Transformer();
$myDictionary = new MyDictionary();
$myTransformer = new Transformer($myDictionary);

$transformer->toWords(15); // mười lăm
$myTransformer->toWords(15); // mười nhăm
```

Dành cho nhà phát triển
-----------------------

[](#dành-cho-nhà-phát-triển)

Nếu như bạn cảm thấy thư viện còn thiếu sót hoặc sai sót và bạn muốn đóng góp để phát triển chung, chúng tôi rất hoan nghênh! Hãy tạo các `issue` để đóng góp ý tưởng cho phiên bản kế tiếp hoặc tạo `PR` để đóng góp. Cảm ơn!

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 84.3% 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 ~96 days

Recently: every ~210 days

Total

10

Last Release

1675d ago

PHP version history (2 changes)1.0.0PHP ^7.1

1.2.1PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/8901d64a1059726b851dbdd91463ad1d3169f9dba6a2dcff11d05f97d9bccaea?d=identicon)[vuongxuongminh](/maintainers/vuongxuongminh)

---

Top Contributors

[![vuongxuongminh](https://avatars.githubusercontent.com/u/38932626?v=4)](https://github.com/vuongxuongminh "vuongxuongminh (43 commits)")[![nhamtphat](https://avatars.githubusercontent.com/u/20165130?v=4)](https://github.com/nhamtphat "nhamtphat (8 commits)")

---

Tags

number-to-wordsphpvietvietnamesenumber to wordsphpviet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpviet-number-to-words/health.svg)

```
[![Health](https://phpackages.com/badges/phpviet-number-to-words/health.svg)](https://phpackages.com/packages/phpviet-number-to-words)
```

###  Alternatives

[riskihajar/terbilang

Number to words conversion support multi language.

134159.5k](/packages/riskihajar-terbilang)[sensiolabs/minify-bundle

Assets Minifier (CSS, JS) for Symfony &amp; Minify integration in Asset Mapper

5694.9k1](/packages/sensiolabs-minify-bundle)[sider/phinder

PHP code piece finder

5445.5k](/packages/sider-phinder)

PHPackages © 2026

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