garethhall Posted September 24, 2009 Share Posted September 24, 2009 Hello how can a round to the second decimal. If I do <?php $value = "49.95"; $ex_gst = $value*8/9; echo round($ex_gst, 2); ?> So the result is correst in this case 44.4 But I want it to say 44.40? How? Link to comment https://forums.phpfreaks.com/topic/175312-solved-math-help-rounding/ Share on other sites More sharing options...
Garethp Posted September 24, 2009 Share Posted September 24, 2009 echo number_format(round($ex_gst, 2),2); Link to comment https://forums.phpfreaks.com/topic/175312-solved-math-help-rounding/#findComment-923936 Share on other sites More sharing options...
Daniel0 Posted September 24, 2009 Share Posted September 24, 2009 If you're going to use number_format(), using round() is redundant. It already knows how to round numbers: number_format($ex_gst, 2); Link to comment https://forums.phpfreaks.com/topic/175312-solved-math-help-rounding/#findComment-923962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.