PHPackages                             furthestworld/unitformat - 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. furthestworld/unitformat

ActiveLibrary

furthestworld/unitformat
========================

一个数据单位格式化的PHP组件

v1.0.4(8y ago)0279MITPHPPHP &gt;=5.5.19

Since Dec 29Pushed 8y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (8)Used By (0)

unitFormat
==========

[](#unitformat)

一个数据单位格式化的PHP组件

功能
==

[](#功能)

提供数据的自动进位、格式化，并匹配单位

安装
==

[](#安装)

- 在项目的composer.json文件中的require项中添加：

```
"furthestworld/unitformat": "~1.0"

```

并更新composer依赖：`composer update`

- 在需要使用的地方添加：

```
require_once __ROOT__ . '/vendor/autoload.php';
use FurthestWorld\UnitFormat\Src\UnitFormat;

```

用法
==

[](#用法)

```
$origin_data    = [
    '2345124332',
    '3433443432',
    '12243433332',
    '7852323436'
];
$formatted_data = UnitFormat::formatDataUnit($origin_data, 10000, ['次', '万次', '亿次'], [1]);
var_dump($formatted_data);

```

输出结果：

```
array(2) {
  ["unit"]=>
  string(6) "亿次"
  ["data"]=>
  array(4) {
    [0]=>
    string(4) "23.5"
    [1]=>
    string(4) "34.3"
    [2]=>
    string(5) "122.4"
    [3]=>
    string(4) "78.5"
  }
}

```

参数说明
====

[](#参数说明)

`formatDataUnit` 方法
-------------------

[](#formatdataunit-方法)

- $origin\_data ：原始数据。可以是单个值，或者是一个数值数组列表
- $mod ：单位进位的模
- $units ：单位列表
- $number\_format ：使用PHP的number\_format函数自定义参数数组，对应number\_format的后三个参数列表

`updateDataUnit` 方法
-------------------

[](#updatedataunit-方法)

- $origin\_data : 原始数据的引用。 直接对原始数据格式化修改
- $key ：需要格式化的数据数组 key
- $mod ：单位进位的模
- $units ：单位列表
- $number\_format ：使用PHP的number\_format函数自定义参数数组，对应number\_format的后三个参数列表

`updateMultiDataUnit` : 直接对原始数据多组数据格式化修改
----------------------------------------

[](#updatemultidataunit--直接对原始数据多组数据格式化修改)

- $origin\_data : 原始数据的引用。
- $keys : 多个字段格式化设置数组

格式如下：

```
[
    'key1'  => ['mod' => 10000, 'units' => ['次', '万次', '亿次'], 'number_format' => [2, '.', ',']],
    'key2' => ['units' => ['个', '万个', '亿个']]
]

```

其他完善中。。。
--------

[](#其他完善中)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~27 days

Recently: every ~40 days

Total

7

Last Release

3257d ago

Major Versions

v0.0.1 → v1.0.02016-12-29

v0.0.2 → v1.0.22016-12-29

PHP version history (2 changes)v0.0.1PHP &gt;=5.6.19

v1.0.4PHP &gt;=5.5.19

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

phpunitFormat

### Embed Badge

![Health badge](/badges/furthestworld-unitformat/health.svg)

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

###  Alternatives

[pestphp/pest-plugin-stressless

Stressless plugin for Pest

67792.6k16](/packages/pestphp-pest-plugin-stressless)

PHPackages © 2026

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