Php function integer number to text conversion


codethathelpsyou

Here is a PHP function for how the number can be converted to text

<!–?php

function integer_to_text($no)
{
$words = array(‘0’=> ” ,

                                 ‘1’=> ‘one’ ,’2’=> ‘two’ ,’3′ => ‘three’,’4′ => ‘four’,

                                ‘5’ => ‘five’,  ‘6’ => ‘six’,’7′ => ‘seven’,’8′ => ‘eight’,

                               ‘9’ => ‘nine’,’10’ => ‘ten’,’11’ => ‘eleven’, ’12’ => ‘twelve’,

                             ’13’ => ‘thirteen’,’14’ => ‘fouteen’,’15’ => ‘fifteen’,’16’ => ‘sixteen’,
’17’ => ‘seventeen’,’18’ => ‘eighteen’,’19’ => ‘nineteen’,’20’ => ‘twenty’,

                            ’30’ => ‘thirty’,’40’ => ‘fourty’,’50’ => ‘fifty’,’60’ => ‘sixty’,’70’ => ‘seventy’,

                           ’80’ => ‘eighty’,’90’ => ‘ninty’, ‘100’ => ‘hundred’,’1000′ => ‘thousand’,

                         ‘100000’ => ‘lakh’,’10000000′ => ‘crore’);

if($no == 0)
return ‘ ‘;
else {           $novalue=”;$highno=$no;$remainno=0;$value=100;$value1=1000;
while($no>=100)    {
if(($value <= $no) &&($no  < $value1))    {
$novalue=$words[“$value”];
$highno = (int)($no/$value);
$remainno = $no % $value;
break;
}
$value= $value1;
$value1 = $value * 100;
}
if(array_key_exists(“$highno”,$words))
return $words[“$highno”].” “.$novalue.” “.integer_to_text($remainno);
else {
$unit=$highno%10;
$ten…

View original post 58 more words

Advertisements
About

myself pramodh kumar yet another php developer from India and have worked on oops,procedural,yii framework,codeigniter,wordpress,joomla,api and more.

Tagged with: ,
Posted in php

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow php tutorial on WordPress.com
categories
Calendar
April 2014
M T W T F S S
« Mar   May »
 123456
78910111213
14151617181920
21222324252627
282930  
Follow me on Twitter
Blog Stats
  • 74,625 hits
%d bloggers like this: