Laravel package to convert English numbers to Bangla number or Bangla text, Bangla month name and Bangla Money Format for Laravel 9.x, 10.x, 11.x, and 12.x.
Maximum possible number to convert in Bangla word is 999999999999999
| Operation | English Input | Bangla Output |
|---|---|---|
| Text (Integer) | 13459 | তেরো হাজার চার শত ঊনষাট |
| Text (Float) | 1345.05 | এক হাজার তিন শত পঁয়তাল্লিশ দশমিক শূন্য পাঁচ |
| Number | 1345.5 | ১৩৪৫.৫ |
| Text Money Format | 1345.50 | এক হাজার তিন শত পঁয়তাল্লিশ টাকা পঞ্চাশ পয়সা |
| Month | 12 | ডিসেম্বর |
| Comma (Lakh) | 121212121 | ১২,১২,১২,১২১ |
- PHP 8.0 or higher
- Laravel 9.x, 10.x, 11.x, or 12.x
composer require rakibhstu/number-to-bangla:^2.0use Rakibhstu\Banglanumber\NumberToBangla;
$numto = new NumberToBangla();
echo $numto->bnNum(12345);
// Output: ১২৩৪৫
echo $numto->bnNum(1234.56);
// Output: ১২৩৪.৫৬echo $numto->bnWord(12345);
// Output: বারো হাজার তিন শত পঁয়তাল্লিশ
echo $numto->bnWord(1345.05);
// Output: এক হাজার তিন শত পঁয়তাল্লিশ দশমিক শূন্য পাঁচecho $numto->bnCommaLakh(1234567);
// Output: ১২,৩৪,৫৬৭echo $numto->bnPercentage(75.5);
// Output: ৭৫.৫%
echo $numto->bnPercentage(75.5, asWord: true);
// Output: পঁচাত্তর দশমিক পাঁচ শতাংশecho $numto->bnMoney(5000);
// Output: পাঁচ হাজার টাকা
echo $numto->bnMoney(5000.50);
// Output: পাঁচ হাজার টাকা পঞ্চাশ পয়সাecho $numto->bnMonth(1);
// Output: জানুয়ারি
echo $numto->bnMonth(12);
// Output: ডিসেম্বরecho $numto->bnDay(1);
// Output: রবিবার
echo $numto->bnDay('monday');
// Output: সোমবারecho $numto->bnTime('14:30');
// Output: দুপুর ২:৩০
echo $numto->bnTime('14:30', asWord: true);
// Output: দুপুর দুইটা ত্রিশ মিনিট
echo $numto->bnTime('09:15', asWord: true);
// Output: সকাল নয়টা পনেরো মিনিটecho $numto->bnDuration(3665);
// Output: ১ ঘন্টা ১ মিনিট ৫ সেকেন্ড
echo $numto->bnDuration(90);
// Output: ১ মিনিট ৩০ সেকেন্ডecho $numto->bnBengaliMonth(1);
// Output: বৈশাখ
echo $numto->bnSeason(1);
// Output: গ্রীষ্ম
echo $numto->bnSeason(5);
// Output: শীতecho $numto->bnAge('1990-01-15');
// Output: ৩৫ বছর
echo $numto->bnAge('1990-01-15', detailed: true);
// Output: ৩৫ বছর ২ মাস ৫ দিনecho $numto->bnDate('2024-01-15');
// Output: ১৫ জানুয়ারি, ২০২৪
---
## Reverse Parsing
### Parse Bangla Numbers to English
```php
$number = $numto->parseNum('১২৩৪৫');
// Output: 12345
$number = $numto->parseNum('১২,৩৪,৫৬৭');
// Output: 1234567$result = $numto->number(12345)
->toBangla()
->asWord()
->withPrefix('মোট: ')
->withSuffix(' টাকা')
->get();
// Output: মোট: বারো হাজার তিন শত পঁয়তাল্লিশ টাকা// As percentage
$result = $numto->number(75.5)
->asPercentage(asWord: true)
->get();
// Output: পঁচাত্তর দশমিক পাঁচ শতাংশ$numbers = [100, 200, 300];
$result = $numto->batch($numbers, 'bnNum');
// Output: ['১০০', '২০০', '৩০০']
$result = $numto->batch($numbers, 'bnWord');
// Output: ['এক শত', 'দুই শত', 'তিন শত']$data = [
'revenue' => 500000,
'expenses' => 200000,
'profit' => 300000
];
$result = $numto->batchWithKeys($data, 'bnCurrency');
// Output: [
// 'revenue' => '৫ লক্ষ টাকা',
// 'expenses' => '২ লক্ষ টাকা',
// 'profit' => '৩ লক্ষ টাকা'
// ]$result = $numto->toArray(12345);
/* Output:
[
'original' => 12345,
'bangla_number' => '১২৩৪৫',
'bangla_word' => 'বারো হাজার তিন শত পঁয়তাল্লিশ',
'money_format' => 'বারো হাজার তিন শত পঁয়তাল্লিশ টাকা',
'comma_format' => '১২,৩৪৫'
]
*/$json = $numto->toJson(12345);
// Returns UTF-8 encoded JSON stringpublic function show($id)
{
$product = Product::find($id);
return response()->json([
'name' => $product->name,
'price' => NumberToBangla::convert($product->price),
'price_words' => NumberToBangla::words($product->price),
'discount' => [
'rate' => app(NumberToBangla::class)->bnPercentage($product->discount),
'amount' => NumberToBangla::money($product->discount_amount)
],
'details' => app(NumberToBangla::class)->toArray($product->price)
]);
}use Rakibhstu\Banglanumber\NumberToBangla;
// In controllers
$banglaNumber = NumberToBangla::convert(12345);
// In Blade
{{ NumberToBangla::words($amount) }}
{{ NumberToBangla::money($total) }}
// In models
public function getPriceAttribute($value)
{
return NumberToBangla::convert($value);
}$discount = $numto->bnPercentage(20);
$final = $numto->bnMoney(20000);
// Stock display
$stock = $numto->bnWord(50) . ' পিস';$marks = $numto->bnNum(85);
$percentage = $numto->bnPercentage(85);// Official documents
$amount = $numto->bnMoney(50000);
$date = $numto->bnDate('2024-01-15');
$age = $numto->bnAge('1990-01-01');- Batch Processing: Use
batch()for multiple conversions - Static Helpers: Use for simple, one-off conversions
- Fluent API: Chain multiple operations efficiently
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email rakib1708@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
If you find this package helpful, please consider giving it a ⭐ on GitHub!