cdoggg94 Posted March 8, 2012 Share Posted March 8, 2012 Bascially i add a couple numbers up and display the sum. sometimes the number is something like this: 234.237 i want it to display : 234.24 i realize its needs "round()" in it but i dont know how to use it.. any help? Link to comment https://forums.phpfreaks.com/topic/258537-rounding-to-2-decimal-places/ Share on other sites More sharing options...
batwimp Posted March 8, 2012 Share Posted March 8, 2012 round($x,2); Link to comment https://forums.phpfreaks.com/topic/258537-rounding-to-2-decimal-places/#findComment-1325246 Share on other sites More sharing options...
cdoggg94 Posted March 8, 2012 Author Share Posted March 8, 2012 Thank you very much ! Works good! is there a reason or a way to have something like 120.5 changed to 120.50? Link to comment https://forums.phpfreaks.com/topic/258537-rounding-to-2-decimal-places/#findComment-1325251 Share on other sites More sharing options...
Nodral Posted March 8, 2012 Share Posted March 8, 2012 number_format($x,2); Link to comment https://forums.phpfreaks.com/topic/258537-rounding-to-2-decimal-places/#findComment-1325252 Share on other sites More sharing options...
batwimp Posted March 8, 2012 Share Posted March 8, 2012 $x= sprintf("%01.2f", $x); Link to comment https://forums.phpfreaks.com/topic/258537-rounding-to-2-decimal-places/#findComment-1325254 Share on other sites More sharing options...
cdoggg94 Posted March 8, 2012 Author Share Posted March 8, 2012 Thank you all! It works perfect! Link to comment https://forums.phpfreaks.com/topic/258537-rounding-to-2-decimal-places/#findComment-1325258 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.