Set precision for a float number in PHP

前端 未结 5 1829
难免孤独
难免孤独 2020-11-28 15:12

I get a number from database and this number might be either float or int.

I need to set the decimal precision of the number to 3

5条回答
  •  庸人自扰
    2020-11-28 15:54

    Its sound like floor with decimals. So you can try something like

    floor($number*1000)/1000
    

提交回复
热议问题