Click to verify
PHP numbers are converted to Chinese characters, and the method of capitalizing the RMB.
10, hundreds, thousands, million, hundreds of thousands, million, million, million, billion, billion, billion, billion, billion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion, trillion; this function multiplied by billion to be a trillion
It starts with "ten", such as fifteen, one hundred thousand, one billion, etc. If the double digit number appears in the middle of the number, it is used as "ten or more", such as one hundred and ten, one thousand and one thousand, one thousand and one thousand.
The issue of "two" and "two". Two hundred million, two thousand, two hundred, all are OK, but 200 can only be twenty, and 200 can be better if 200 is used. 22,2222,222 is "two,222,222,222"
Regarding the issues of "zero" and "0", "zero" is used in numbers, and only the empty spaces in numbers such as page numbers and ages can be used in numbers. No matter how many 0s are in the middle of the digit, they are read as "zero". 2014 is "two thousand and one four", 200014 is "two hundred and one four", 201400 is "two hundred and one four hundred"
Reference: https://jingyan.baidu.com/article/636f38bb3cfc88d6b946104b.html
Reference for writing RMB: Basic regulations for correctly filling in bills and settlement vouchers
php -v >= 5.4
Add in composer.json file
"wilon/php-number2chinese" : " ~1.0 "or
composer require wilon/php-number2chinese#string number2chinese ( mixed $number [, bollen $isRmb] )#
Convert $number to Chinese characters
mixed $number
Enter a number or string. When the number is too large or too small, please enter string to support negative numbers
bollen $isRmb
Default is false. When true, return the maximum unit of RMB capital Chinese characters [knizz] and the minimum unit [milli]
$ num1 = 0.1234567890 ;
echo number2chinese ( $ num1 ); // 零点一二三四五六七八九
echo number2chinese ( $ num1 , true ); // 零元壹角贰分叁厘肆毫
$ num2 = 20000000000000000 ;
echo number2chinese ( $ num2 ); // 两兆
echo number2chinese ( $ num2 , true ); // 贰兆元整
$ num3 = - 1202030 ;
echo number2chinese ( $ num3 ); // 负一百二十万零两千零三十
echo number2chinese ( $ num3 , true ); // 负壹佰贰拾万零贰仟零叁拾元整When the number is too large, enter string
$ num2 = 1234567890.0123456789 ;
echo number2chinese ( $ num2 ); // 十二亿三千四百五十六万七千八百九十点零一二三
echo number2chinese ( $ num2 , true ); // 壹拾贰亿叁仟肆佰伍拾陆万柒仟捌佰玖拾元零壹分贰厘叁毫
$ num2 = ' 1234567890.0123456789 ' ;
echo number2chinese ( $ num2 ); // 十二亿三千四百五十六万七千八百九十点零一二三四五六七八九
echo number2chinese ( $ num2 , true ); // 壹拾贰亿叁仟肆佰伍拾陆万柒仟捌佰玖拾元壹分贰厘叁毫If you want to accurately two decimal places, please first process $num1
$ num1 = 0.1234567890 ;
echo number2chinese ( number_format ( $ num1 , 2 )); // 零点一二
echo number2chinese ( number_format ( $ num1 , 2 ), true ); // 零元壹角贰分 php vendor/wilon/php-number2chinese/test.php // 随机一些数据进行测试
php vendor/wilon/php-number2chinese/test.php 2000 // 指定数字
Any questions? Send issues