Re: Convert Nominal Number into string spelling in PHP

From: Date: Thu, 07 Oct 2004 04:41:57 +0000
Subject: Re: Convert Nominal Number into string spelling in PHP
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-24711@lists.php.net to get a copy of this message
I don't know of a function that does what you want, although I'm sure that such a function has been written many times. If you want to write it yourself then you will need to grab each individual digit that can be done in a simple loop using the modulus and divide operators The following snippet will put the individual digits into an array after that it's should be a case of working on the elements of the array. Element 0-2 hundreds, 3-5 thousands, 6-8 millions etc. Obviously some refining is required to cater for the numbers between ten and twenty. <?php $digit = array(); $number = 123654879; $num = $number; $n = 0; while($num!= 0) { $digit[$n] = $num%10; $num=(int)($num/10); $n++; echo "n = $n, num = $num<BR>"; } // while echo $number; echo "<PRE>"; var_dump($digit); echo "</PRE>"; ?> graeme susilo wrote:
Does everyone know how to convert Nominal Number into string spelling in PHP ?. Like this : Nominal Number : 567.123.560 And the spelling string/word have to be like this : "Five Hundred Sixty Seven Million One Hundred Twenty Three Thousand Five Hundred and Sixty" Please help me..


« previous php.windows (#24711) next »