What is the exact equivalent of JS: something.toFixed() in PHP?

前端 未结 7 1486
Happy的楠姐
Happy的楠姐 2020-12-30 06:36

If I have a.toFixed(3); in javascript (\'a\' being equal to 2.4232) what is the exact equivalent command in php to retrieve that? I searched for it but found n

7条回答
  •  醉酒成梦
    2020-12-30 07:07

    Have you tried this:

    round(2.4232, 2);
    

    This would give you an answer of 2.42.

    More information can be found here: http://php.net/manual/en/function.round.php

提交回复
热议问题