PHP - 缩短整数

时间:2012-11-03 10:37:50

标签: php numbers

我已经看过php round函数了,我认为它没有做到我需要的东西,我不想舍入小数位我想做以下事情:

$variable1 = 200000000 into 200
$variable2 = 20000000 into 20
$variable3 = 2000000 into 2
$variable4 = 200000 into 0.2

有人可以帮助我吗?

我应该补充一点,我不知道变量是什么,所以一次可能是20000000而下一个是380000000

2 个答案:

答案 0 :(得分:2)

Divide数字超过1000000

$num /= 1000000;

答案 1 :(得分:0)

$millionDivide = 1000000;

echo $variable1 = 200000000/$millionDivide;
echo $variable2 = 20000000/$millionDivide;
echo $variable3 = 2000000/$millionDivide;
echo $variable4 = 200000/$millionDivide;