PHP round half up doesn't work

前端 未结 3 550
梦毁少年i
梦毁少年i 2021-01-25 19:40

I have this code


I want to round two decimals to half up, I expect a value as 0.58... but

3条回答
  •  佛祖请我去吃肉
    2021-01-25 20:27

    if you expect 0,58 you don't have to use a "half round" but the ceil function

    $v = 0.575;
    echo ceil($v * 100) / 100; // show 0,58
    

提交回复
热议问题