|
Function name: Exchangemoney ($N _money)
Role: money transfer function
Parameters: $N _money (number of amounts to be converted)
return value: String
Note: Example of this function: $char =exchangemoney (5645132.3155) ==> $char = ' ¥5,645,132.31 '
//-----------------------------------------------------------------------------------
function Exchangemoney ($N _money)
{
$A _tmp=explode (".", $N _money); Divides a number into two parts by a decimal point and deposits it into an array $a_tmp
$I _len=strlen ($A _tmp[0]); Measure the width of the number of digits before the decimal point
if ($I _len%3==0)
{
$I _step= $I _LEN/3; such as the width of the preceding digit mod 3 = 0, can be pressed, divided into the $i_step section
}else
{
$step = ($len-$len%3)/3+1; As the front digit width mod 3! = 0, can be pressed, divided into $i_step part +1
}
$C _cur= "";
Convert amount numbers before decimal point
while ($I _len<>0)
{
$I _step--;
if ($I _step==0)
{
$C _cur. = substr ($A _tmp[0],0, $I _len-($I _step));
}else
{
$C _cur. = substr ($A _tmp[0],0, $I _len-($I _step)). ",";
}
$A _tmp[0]=substr ($A _tmp[0], $I _len-($I _step);
$I _len=strlen ($A _tmp[0]);
}
Convert the amount after the decimal point
if ($A _tmp[1]== "")
{
$C _cur. = ". 00";
}else
{
$I _len=strlen ($A _tmp[1]);
if ($I _len<2)
{
$C _cur. = ".". $A _tmp[1]. " 0 ";
}else
{
$C _cur. = ".". substr ($A _tmp[1],0,2);
}
}
Plus the renminbi sign and out
$C _cur= "¥". $C _cur;
return $C _cur;
}
|