I really hope someone would teach me how to do this.
If you are aware, most of the bank will print the amount of sum of money you deposit or withdraw with wording...
Example: USD8,572.20
Output: EIGHT THOUSAND FIVE HUNDRED SEVENTY TWO AND TWENTY CENTS
how do i achive this with php?
thanks in advance
Number to wording
Moderator: General Moderators
Re: Number to wording
Divide the number by 10 to separate the milions, thousand, hundreds, cents. The results put in an array then using for each division (i.e. millions thousands) make use switch to output the correct word for the number in that position.
For example
This is simple but resource and time consuming. I don' t have a better idea.
For example
Code: Select all
you have 813 dollars
if you divide by ten
you get this array [dollars]=3, [decimal]=1; [hundreds]=8
switch($a[dollars])
case "0":
case "1": valueString="one";Break;
case "2": valueString="two";Break;
etc
Re: Number to wording
thanks for replying. But is there any reliable function for this? I really have no idea how to construct this
Re: Number to wording
There's nothing built into PHP to do it.. You'll have to write it yourself or find an example online somewhere.cade wrote:thanks for replying. But is there any reliable function for this? I really have no idea how to construct this
Re: Number to wording
I have no idea where to start...Hope some experience guys will guide and advise me
Re: Number to wording
Rovas already did.