Skip to content

Instantly share code, notes, and snippets.

@kashohel
Last active April 11, 2023 15:33
Show Gist options
  • Save kashohel/437aabd046e13a5c12d92aa370b8e61c to your computer and use it in GitHub Desktop.
Save kashohel/437aabd046e13a5c12d92aa370b8e61c to your computer and use it in GitHub Desktop.
Convert from English number to word in Bangla | ইংরেজি নাম্বার থেকে বাংলা(কথায়) রুপান্তর
<?php
function num2bangla($number)
{
if (($number < 0) || ($number > 999999999))
{
return "নাম্বারটি অতিরিক্ত বড়";
} elseif (!is_numeric($number))
{
return "বৈধ নাম্বার নয়";
}
$Kt = floor($number / 10000000); /* Koti */
$number -= $Kt * 10000000;
$Gn = floor($number / 100000); /* lakh */
$number -= $Gn * 100000;
$kn = floor($number / 1000); /* Thousands (kilo) */
$number -= $kn * 1000;
$Hn = floor($number / 100); /* Hundreds (hecto) */
$number -= $Hn * 100;
$Dn = floor($number / 10); /* Tens (deca) */
$n = $number % 10; /* Ones */
$res = "";
if ($Kt)
{
$res .= num2bangla($Kt) . " কোটি ";
}
if ($Gn)
{
$res .= num2bangla($Gn) . " লাখ";
}
if ($kn)
{
$res .= (empty($res) ? "" : " ") .
num2bangla($kn) . " হাজার";
}
if ($Hn)
{
$res .= (empty($res) ? "" : " ") .
num2bangla($Hn) . " শত";
}
$hund = ["", "এক", "দুই", "তিন", "চার", "পাঁচ", "ছয়", "সাত", "আট", "নয়", "দশ",
"এগার", "বার", "তের", "চৌদ্দ", "পনের", "ষোল", "সতের", "আঠার", "ঊনিশ", "বিশ",
"একোশ", "বাইশ", "তেইশ", "চব্বিশ", "পঁচিশ", "ছাব্বিশ", "সাতাশ", "আঠাশ", "ঊনত্রিশ", "ত্রিশ",
"একত্রিশ", "বত্রিশ", "তেত্রিশ", "চৌত্রিশ", "পয়ত্রিশ", "ছত্রিশ", "সতত্রিশ", "আটত্রিশ", "ঊনচল্লিশ", "চল্লিশ",
"একচল্লিশ", "বেয়াল্লিশ", "তেতাল্লিশ", "চোয়াল্লিশ", "পঁয়তাল্লিশ", "ছেচল্লিশ", "সতচল্লিশ", "আটচল্লিশ", "ঊনপঞ্চাশ", "পঞ্চাশ",
"একান্ন", "বাহান্ন", "তেপান্ন", "চোয়ান্ন", "পঁঞ্চান্ন", "ছাপ্পান্ন", "সাতান্ন", "আটান্ন", "ঊনষাট", "ষাট",
"একষট্টি", "বাষট্টি", "তেষট্টি", "চৌষট্টি", "পঁয়ষট্টি", "ছেষট্টি", "সতাষট্টি", "আটষট্টি", "ঊনসত্তর", "সত্তর",
"একাত্তর", "বাহাত্তর", "তেহাত্তর", "চোয়াত্তর", "পঁচাত্তর", "ছিয়াত্তর", "সাতাত্তর", "আটাত্তর", "ঊনআশি", "আশি",
"একাশি", "বিরাশি", "তিরাশি", "চোরাশি", "পঁচাশি", "ছিয়াশি", "সাতাশি", "অটাশি", "ঊননব্বই", "নব্বই",
"একানব্বই", "বিরানব্বই", "তিরানব্বই", "চুরানব্বই", "পঁচানব্বই", "ছিয়ানব্বই", "সাতানব্বই", "আটানব্বই", "নিরানব্বই", "একশ"];
if ($Dn || $n)
{
if (!empty($res))
{
$res .= " ";
}
$res .= $hund[$Dn * 10 + $n];
}
if (empty($res))
{
$res = "শূন্য";
}
return $res;
}
$chequeNow = 87474840;
echo $chequeNow ." = ". num2bangla($chequeNow);
?>
@kashohel
Copy link
Author

Inspiration from TechJewel

@tareqhi
Copy link

tareqhi commented Jul 19, 2018

অসাধারণ, সত্যিই কাজে লেগেছে। ধন্যবাদ।

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment