format....not international........

From: Date: Wed, 22 Aug 2001 03:33:38 +0000
Subject: format....not international........
Groups: php.windows 
Request: Send a blank email to php-windows+get-8987@lists.php.net to get a copy of this message
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

« previous php.windows (#8987) next »