Round Decimal Value并从PHP中的值中删除0.或0.0

时间:2017-05-11 06:07:25

标签: php

以下是我的代码

$number1 = "0.125";
$number2 = "0.05";
echo $total1 = round($number1,2);
echo $total2 = round($number2,2);

我得到的是输出

0.13 ---- output I want is : 13
0.05 ---- output I want is : 5

未获得所需的输出

1 个答案:

答案 0 :(得分:0)

试试这个:

$number1 = "0.125";
$number2 = "0.05";
$total1 = round($number1,2) * 100;
$total2 = round($number2,2) * 100;

echo $total1 . "\n" .$total2;

Example