【发布时间】:2015-09-17 05:46:46
【问题描述】:
我目前正在一个网站上工作,我需要转换后面带有字母的金额,例如:
100M = 100.000.000
我已经创建了另一种方法,来自:
100.000.000 = 100M
这是我目前的功能:
function Convert($Input){
if($Input<=1000){
$AmountCode = "GP";
$Amount = $Input;
}
else if($Input>=1000000){
$AmountCode = "M";
$Amount = floatval($Input / 1000000);
}
else if($Input>=1000){
$AmountCode = "K";
$Amount = $Input / 1000;
}
$Array = array(
'Amount' => $Amount,
'Code' => $AmountCode
);
$Result = json_encode($Array);
return json_decode($Result);
}
现在我需要一些可以过滤掉这个的东西:
100GP = 100
100K = 100.000
100M = 100.000.000
我一直在寻找一些东西,并尝试使用explode(); 和其他功能,但它并没有像我想要的那样工作..
有谁能帮帮我吗?
【问题讨论】: