Giter VIP home page Giter VIP logo

number_in_chinese's Introduction

number_in_chinese

将数字转换为中文汉字的简单php组件。支持整数与浮点数,简繁体输出,目前不支持负数。

Tests StyleCI build status Code Coverage Latest Stable Version Latest Unstable Version License

环境需求

  • PHP >= 7.3

安装

$ composer require coolert/number_in_chinese -vvv

使用

use Coolert\NumberInChinese\Convert;
$convert = new Convert();
echo $response;

数字转换成中文

$response = $convert->convertNumbers('1234567890');

示例:

一亿二千三百四十五万七千八百九十

参数说明

string convertNumbers(string $number, int $dic = 1, int $unit_dic = 1)
  • $number - 需要转换的数字
  • $dic - 转换成的数字位类型:1:小写,数字'0'用'零’表示 2:小写,数字'0'用'〇‘表示 3:大写('壹','贰','叁'...)
  • $unit_dic - 转换后的单位类型:1:简体中文 2:繁体中文

在Laravel中使用

你可以有两种方式获取Coolert\NumberInChinese\Convert实例:

方法参数注入

public function index(Convert $convert)
{
    $response = $convert->convertNumbers('123457890');
}

服务名访问

public fuction index()
{
    $response = app('convert')->convertNumbers('123457890');
}

License

MIT

number_in_chinese's People

Contributors

coolert avatar stylecibot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.