简体   繁体   English

如何对总价值的数字取整

[英]How to round figure of sum value

How to round figure of echo sum value 如何对回波总和值进行四舍五入

<?php echo (90+10)*15*732/365/30 ;   ?>

this code showing like this 此代码显示如下

100.27397260274 100.27397260274

and I want like this 我想要这样

100.300 100.300

and I am using like this but this is also not working 我正在使用这样的东西,但这也不起作用

<?php echo ((round((90+10)*15*732/365/30, 1)),3) ;   ?>

how can I do this? 我怎样才能做到这一点?

Do this: 做这个:

<?php echo round( (90+10)*15*732/365/30 , 2 ); ?>

and the output will be: 输出将是:

100.27 100.27

and for 100.3 you can do 而对于100.3您可以

<?php echo round( (90+10)*15*732/365/30,1 ); ?>

and for 100.300 you need to use extra function number_format() with the 3 for the value of decimals: 对于100.300您需要使用额外的函数number_format()3作为小数的值:

<?php echo number_format( round((90+10)*15*732/365/30,1), 3 ); ?>

采用

round(number,decimal_place);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM