Today Ayon came up with a problem that he needs to convert English digits to Bangla. The Input would be something like “1 ডলার = 81.55 টাকা” and the output should be “১ ডলার = ৮১.৫৫ টাকা”. How to do it?
Its very easy to do. In fact most developers will be able to do it within few minutes. I just want to share my solution.
I use PHP’s str_replace function.
[code language=”PHP”] $bn_digits=array(‘০’,’১’,’২’,’৩’,’৪’,’৫’,’৬’,’৭’,’৮’,’৯’);
$output = str_replace(range(0, 9),$bn_digits, $input); [/code]
Thats it. You can wrap it with a function and re use it.