0

How 1000 10,000 1,00,000 number converting in php?

i mean splitting numbers like
100 1000 10000 100000
to
100 1,000 10,000 1,00,000
with ' , ' thousand, lack, crores...

Edited by tnguru: n/a

4
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by rotten69
0

Wow.. That's a big number.. I think You should have a look at PHP site that is posted up there.. .

0

ok finaly i got the code

function no_to_words($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." ".no_to_words($remainno);
          else {
             $unit=$highno%10;
             $ten =(int)($highno/10)*10;            
             return $words["$ten"]." ".$words["$unit"]." ".$novalue." ".no_to_words($remainno);
           }
    }
}

$org_num = "5255255";
echo "<br>org: ".$org_num; 
echo "<br>number_format: ".number_format($org_num) . '<br /> in words: ' .no_to_words($org_num);
1

i got that. thanks for the repley i just post here for code example. r u tried that? have any idea

What does this mean? You mean that you're already aware of this, but just wanted to make somebody write code for you anyway?

You've been given a link that contains examples, so I'd say you're all solved.

Votes + Comments
Better count to 1,000,000,000 ;)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.