PHP to round up to the 2nd decimal place

前端 未结 2 1637
甜味超标
甜味超标 2021-01-15 06:04

By calculating areas I have a number which I need to display in a strange way.

Always display 2 decimal places. Always round up the 2nd decimal place if the 3rd+ de

2条回答
  •  时光取名叫无心
    2021-01-15 06:34

    To always round up you will want to use something like this:

    $number = 0.8701;
    
    echo ceil($number*100)/100;
    
    // = 0.88
    

提交回复
热议问题