jayen/number-converter
Composer 安装命令:
composer require jayen/number-converter
包简介
Laravel package to convert numbers written in words into integers.
README 文档
README
A Laravel package to convert numbers written in words into numeric values, and vice versa.
✨ Features
- Convert
"two hundred million"→200000000 - Convert
"Three Hundred Thousand"→300000 - Convert
200000000→"two hundred million" - Convert
300000→"Three Hundred Thousand" - Format
1234567.89→₹12,34,567.89 - Format
1234567.89with currency code"USD"→$1,234,567.89 - Convert
12345678.89with currency code"INR"→"one crore, twenty-three lakh, forty-five thousand, six hundred and seventy-eight rupees and eighty-nine paise"
📦 Installation
Install via Packagist using Composer:
composer require jayen/number-converter
🚀 Usage
Using the Facade
use Jayen\NumberConverter\Facades\NumberConverter; $number = NumberConverter::wordsToNumber("One Thousand Two Hundred Thirty Four"); // Output: 1234 $words = NumberConverter::numberToWords("1234"); // Output: one thousand, two hundred and thirty-four $currency = NumberConverter::formatCurrency(1234567.89, 'USD'); // Output: $1,234,567.89 $withoutSymbol = NumberConverter::formatCurrency(1234567.89, 'INR', false); // Output: INR 12,34,567.89 $currencyWords = NumberConverter::numberToCurrencyWords(12345678.89, 'INR'); // Output: one crore, twenty-three lakh, forty-five thousand, six hundred and seventy-eight rupees and eighty-nine paise $usdWords = NumberConverter::numberToCurrencyWords(1234567.89, 'USD'); // Output: one million, two hundred and thirty-four thousand, five hundred and sixty-seven dollars and eighty-nine cents
Using Dependency Injection
use Jayen\NumberConverter\NumberConverter; public function convert(NumberConverter $converter) { $number = $converter->wordsToNumber("Five Million Six Hundred"); // Output: 5600000 $words = $converter->numberToWords("5600000"); // Output: Five Million Six Hundred $number = $converter->wordsToNumber("Twelve Lakh Thirty Four Thousand Five Hundred Sixty Seven"); // Output: 1234567 $amount = $converter->formatCurrency(1234567.89, 'INR'); // Output: ₹12,34,567.89 $amountWords = $converter->numberToCurrencyWords(1234567.89, 'USD'); // Output: one million, two hundred and thirty-four thousand, five hundred and sixty-seven dollars and eighty-nine cents }
Currency Codes
NumberConverter::formatCurrency(1234567.89, 'INR'); // ₹12,34,567.89 NumberConverter::formatCurrency(1234567.89, 'USD'); // $1,234,567.89 NumberConverter::formatCurrency(1234567.89, 'EUR'); // €1,234,567.89 NumberConverter::formatCurrency(1234567.89, 'GBP'); // £1,234,567.89 NumberConverter::formatCurrency(1234567.89, 'JPY'); // ¥1,234,568
Currency Words
NumberConverter::numberToCurrencyWords(12345678.89, 'INR'); // one crore, twenty-three lakh, forty-five thousand, six hundred and seventy-eight rupees and eighty-nine paise NumberConverter::numberToCurrencyWords(1234567.89, 'USD'); // one million, two hundred and thirty-four thousand, five hundred and sixty-seven dollars and eighty-nine cents NumberConverter::numberToCurrencyWords(1234567.89, 'JPY'); // one million, two hundred and thirty-four thousand, five hundred and sixty-eight yen
Supported currency codes: INR, USD, EUR, GBP, JPY, AUD, CAD, CNY, AED.
📜 License
This package is open-sourced software licensed under the MIT license.
jayen/number-converter 适用场景与选型建议
jayen/number-converter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 08 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jayen/number-converter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jayen/number-converter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-19