In PHP, how to print a number with 2 decimals, but only if there are decimals already?

前端 未结 6 995
抹茶落季
抹茶落季 2021-01-14 08:33

I have a basic index.php page with some variables that I want to print in several places - here are the variables:



        
6条回答
  •  孤城傲影
    2021-01-14 09:11

    Alternatively way to print

    $number = sprintf('%0.2f', $numbers); 
       // 520.89898989 -> 520.89
    

提交回复
热议问题