我正在尝试用两个千分之二的数字进行子运算,这些数字的格式如下,但我无法在没有前导"dot"
作为分隔符的情况下使用number_format()
函数来获得thousand
显示,并按如下方式计算。
获得结果0032安装仅32
<?php
$a = "1.545"; // how to format this to 1545? (here could be 0, 1, 6, 10, 54, 389, 600, 1600, 5000)
$b = "1.513"; // how to format this to 1545? (here could be 0, 1, 6, 10, 54, 389, 600, 1600, 5000)
$c = $a- $b; // subtraction
echo $c; // result 0,032 instad of just 32
?>
如何将1.545格式化为1545,然后执行子动作?
成功了!结果32
<?php
$a = "1.545";
$b = "1.513";
$c = intval(str_replace('.','',$a))-intval(str_replace('.','',$b));
echo $c;
?>