Re: Convert Nominal Number into string spelling in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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..







-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux