Re: currency format.... not international format

From: Date: Thu, 23 Aug 2001 03:44:38 +0000
Subject: Re: currency format.... not international format
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-9031@lists.php.net to get a copy of this message
Hello; There is a standard function that do this: number_format Take a look in this: http://www.php.net/manual/en/function.number-format.php Best Wishes; Carlos Henrique; At 15:44 21/8/2001 +0530, sur-php wrote: >Hello php-windows, >any body know how to do this ? >suppose there is a input number "12345678.23" >i want output to be like this "1,23,45,678.23" >i don't need output in international format... >that means not like this fomrmat "12,345,678.23" >(it is the format used in our country) > >so this is what i did... >------------------------------------------------------------------------------------- ><? >function convcurr($a) >{ >$nadael=substr($a,-2,1); >$nadael2=substr($a,-1); >if ($nadael===".") {$a=$a."0";} >elseif ($nadael2===".") {$a=$a."00";} > >$check=strpos($a,'.'); >$check1=strlen($check); >if ($check1==0 and $a<>0) {$a=$a.".00";} > >$b=strlen($a); >$c=strpos($a,"."); >$d=substr("$a",$c); >$e=substr("$a",0,-($b-$c)); >$f=strlen($e); >$aa=""; > >for ($i=1;$i<$f+1;$i++) > { > $g=substr("$e",-$i,1); > $aa=$g.$aa; > > if($i==3){$aa=",".$aa;} > if($i==5 and $i<$f){$aa=",".$aa;} > if($i==7 and $i<$f){$aa=",".$aa;} > if($i==9 and $i<$f){$aa=",".$aa;} > if($i==11 and $i<$f){$aa=",".$aa;} > if($i==13 and $i<$f){$aa=",".$aa;} > } > >$summa=$aa.$d; >$replace=str_replace("-,","-",$summa); >$issmall=strlen($replace); >if ($issmall<8) {$replace=str_replace(",","",$replace);} >echo "$replace"; >} >?> > >------------------------------------------------------------------------------------- > >this works for me... >it should be used in this was >------------------------------------------------------------------------------------- ><? >include ("curr-convert.php"); >$a="12345678.23" >convcurr($a); >?> >------------------------------------------------------------------------------------- >but i think there must be some easy way.... >can anyone can give idea about it ? >i think you understood what i wrote here... > > > >-- >Best regards, > sur-php mailto:sur_php@yahoo.com > > > >-- >PHP Windows Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net >For additional commands, e-mail: php-windows-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net > > >--- >Incoming mail is certified Virus Free. >Checked by AVG anti-virus system (http://www.grisoft.com). >Version: 6.0.268 / Virus Database: 140 - Release Date: 7/8/2001

« previous php.windows (#9031) next »