Advertisement
touhid_xml

Number to Bangla

Apr 18th, 2018
867
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function num2bangla($number)
  4. {
  5.     if (($number < 0) || ($number > 999999999))
  6.     {
  7.         return "নাম্বারটি অতিরিক্ত বড়";
  8.     } elseif (!is_numeric($number))
  9.     {
  10.         return "বৈধ নাম্বার নয়";
  11.     }
  12.     $Kt = floor($number / 10000000); /* Koti */
  13.     $number -= $Kt * 10000000;
  14.     $Gn = floor($number / 100000);  /* lakh  */
  15.     $number -= $Gn * 100000;
  16.     $kn = floor($number / 1000);     /* Thousands (kilo) */
  17.     $number -= $kn * 1000;
  18.     $Hn = floor($number / 100);      /* Hundreds (hecto) */
  19.     $number -= $Hn * 100;
  20.     $Dn = floor($number / 10);       /* Tens (deca) */
  21.     $n = $number % 10;               /* Ones */
  22.     $res = "";
  23.     if ($Kt)
  24.     {
  25.         $res .= num2bangla($Kt) . " কোটি ";
  26.     }
  27.     if ($Gn)
  28.     {
  29.         $res .= num2bangla($Gn) . " লাখ";
  30.     }
  31.     if ($kn)
  32.     {
  33.         $res .= (empty($res) ? "" : " ") .
  34.             num2bangla($kn) . " হাজার";
  35.     }
  36.     if ($Hn)
  37.     {
  38.         $res .= (empty($res) ? "" : " ") .
  39.             num2bangla($Hn) . " শত";
  40.     }
  41.     $hund = ["", "এক", "দুই", "তিন", "চার", "পাঁচ", "ছয়", "সাত", "আট", "নয়", "দশ",
  42.         "এগার", "বার", "তের", "চৌদ্দ", "পনের", "ষোল", "সতের", "আঠার", "ঊনিশ", "বিশ",
  43.         "একোশ", "বাইশ", "তেইশ", "চব্বিশ", "পঁচিশ", "ছাব্বিশ", "সাতাশ", "আঠাশ", "ঊনত্রিশ", "ত্রিশ",
  44.         "একত্রিশ", "বত্রিশ", "তেত্রিশ", "চৌত্রিশ", "পয়ত্রিশ", "ছত্রিশ", "সতত্রিশ", "আটত্রিশ", "ঊনচল্লিশ", "চল্লিশ",
  45.         "একচল্লিশ", "বেয়াল্লিশ", "তেতাল্লিশ", "চোয়াল্লিশ", "পঁয়তাল্লিশ", "ছেচল্লিশ", "সতচল্লিশ", "আটচল্লিশ", "ঊনপঞ্চাশ", "পঞ্চাশ",
  46.         "একান্ন", "বাহান্ন", "তেপান্ন", "চোয়ান্ন", "পঁঞ্চান্ন", "ছাপ্পান্ন", "সাতান্ন", "আটান্ন", "ঊনষাট", "ষাট",
  47.         "একষট্টি", "বাষট্টি", "তেষট্টি", "চৌষট্টি", "পঁয়ষট্টি", "ছেষট্টি", "সতাষট্টি", "আটষট্টি", "ঊনসত্তর", "সত্তর",
  48.         "একাত্তর", "বাহাত্তর", "তেহাত্তর", "চোয়াত্তর", "পঁচাত্তর", "ছিয়াত্তর", "সাতাত্তর", "আটাত্তর", "ঊনআশি", "আশি",
  49.         "একাশি", "বিরাশি", "তিরাশি", "চোরাশি", "পঁচাশি", "ছিয়াশি", "সাতাশি", "অটাশি", "ঊননব্বই", "নব্বই",
  50.         "একানব্বই", "বিরানব্বই", "তিরানব্বই", "চুরানব্বই", "পঁচানব্বই", "ছিয়ানব্বই", "সাতানব্বই", "আটানব্বই", "নিরানব্বই", "একশ"];
  51.     if ($Dn || $n)
  52.     {
  53.         if (!empty($res))
  54.         {
  55.             $res .= " ";
  56.         }
  57.         $res .= $hund[$Dn * 10 + $n];
  58.     }
  59.     if (empty($res))
  60.     {
  61.         $res = "শূন্য";
  62.     }
  63.     return $res;
  64. }
  65. $chequeNow = 25790;
  66. echo $chequeNow ." = ". num2bangla($chequeNow);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement