Jan 28, 2011 - PHP    16 Comments

PHP: Convert number & currency to text in asian i.e. Bangladeshi, Indian format

Hello Guys,

I am from Bangladesh and our currency system is somewhat different. We use lac/lakh, crore etc. So, today I had to convert number to word in a project. When I was searching the web, I did not found anything that meets my requirement 100%. So I wrote one. Although my code does not support more than 999 crore taka / rupee, I think this will suffice most of the projects requirements.

To be frank I used several pieces of beautiful code from internet.

Well. Enough talks. Let me show the code.

CODE:

================================================

Sample Output:

================================================

84,20,202.10 : Eighty Four Lakh Twenty Thousand Two Hundred And Two Taka & Ten Paisa Only
10,90,495.20 : Ten Lakh Ninety Thousand Four Hundred And Ninety Five Taka & Twenty Paisa Only
12,51,706.30 : Twelve Lakh Fifty One Thousand Seven Hundred And Six Taka & Thirty Paisa Only
78,31,550.40 : Seventy Eight Lakh Thirty One Thousand Five Hundred And Fifty Taka & Forty Paisa Only
49,59,035.50 : Forty Nine Lakh Fifty Nine Thousand Thirty Five Taka & Fifty Paisa Only
29,83,538.60 : Twenty Nine Lakh Eighty Three Thousand Five Hundred And Thirty Eight Taka & Sixty Paisa Only
50,70,303.70 : Fifty Lakh Seventy Thousand Three Hundred And Three Taka & Seventy Paisa Only
11,98,440.80 : Eleven Lakh Ninety Eight Thousand Four Hundred And Forty Taka & Eighty Paisa Only
70,08,871.90 : Seventy Lakh Eight Thousand Eight Hundred And Seventy One Taka & Ninety Paisa Only

================================================

That’s it!

Please feel free to use this code anytime anywhere.

If you update/enhance this code, please share with other people.

Thanks for reading.

16 Comments

  • cam the same script be used for other currencies?

  • @ Fleix

    well. the indian or more generally the asian currency format is somewhat different than the western countries. as i do not know your currency format, i cannot give you specific answer. for western currencies, you know PHP’s built-in number_format() is enough to take care of the issue.

  • when i tried to run this script, i am facing an error on line 35.

    Parse error: parse error, unexpected ‘;’ in C:\Apache2\htdocs\iqbalavenue\currency.php on line 35

    can u please explain what is this ?

    regards

  • @ Shahid

    what is the line of code exactly?

  • this is the line:

    if($i%2!=0 && $i!=0 && $i!=$lpcount-1)

    i have found another solution for the same purpose. but i will feel happy if you guide me about the error.

    regards

  • can u guide me how u created this website. i am very pleased to see.

    regards

  • Hi,
    This is a joomla site right.
    Really good to see ur post.I am also a web developer like u

  • @ Rashmi

    No. It is a wordpress site. WordPress is much better than Joomla. Thanks. Nice to hear you are a programmer.

  • can u tell me how can i get such like these templates.

    thanks in advance.

  • A simple function used here in this thread

    http://www.daniweb.com/web-development/php/threads/147286

  • Nice coding. Can i use this code to codigniter template.

  • thank you for your kind help.

  • thnanks for the help..

  • Hi admin..

    Thanks for this code. It works properly.
    But I need such a program which took input through the text box. And display the output. Can you help me. And your site design is nice..

    Thanks.:)

  • Please gift me this WordPress template.

Got anything to say? Go ahead and leave a comment!