ab_tanjir

Convert english number to bangla

Jul 9th, 2019
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. class Converter
  2. {
  3.     public static $bn = ["১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯", "০"];
  4.     public static $en = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
  5.  
  6.     public static function bn2en($number)
  7.     {
  8.         return str_replace(self::$bn, self::$en, $number);
  9.     }
  10.  
  11.     public static function en2bn($number)
  12.     {
  13.         return str_replace(self::$en, self::$bn, $number);
  14.     }
  15. }
  16.  
  17. $a = '১২'; //(12)
  18. $b = '৫'; //(5)
  19.  
  20. $c = Converter::bn2en($a) + Converter::bn2en($b); // $c = 17
  21. echo Converter::en2bn($c); // ১৭
Advertisement
Add Comment
Please, Sign In to add comment