Delete digits after two decimal points, without rounding the value

后端 未结 15 1610
死守一世寂寞
死守一世寂寞 2020-11-29 01:04

i have value in php variable like that

$var=\'2.500000550\';
echo $var

what i want is to delete all decimal points after 2 digits.

15条回答
  •  广开言路
    2020-11-29 01:33

    If you don't want to round the number but you want to remove the decimal places you can use "substr" method

    substr(string, start, length);
    substr(4.96, 0, -1);
    

提交回复
热议问题