common Posted February 17, 2009 Share Posted February 17, 2009 hi i'm busy with a php practical and need help with decimal numbers. The worked out a sum and its answer displays 18.5953893. I need it show only 2 numbers after the break, like 18.60 Can anyone help me plz?? Link to comment https://forums.phpfreaks.com/topic/145624-decimal-numbers/ Share on other sites More sharing options...
drisate Posted February 17, 2009 Share Posted February 17, 2009 Try this ;-) www.php.net/number-format Link to comment https://forums.phpfreaks.com/topic/145624-decimal-numbers/#findComment-764506 Share on other sites More sharing options...
Brian W Posted February 17, 2009 Share Posted February 17, 2009 round($number, 2) will return the number rounded to two decimal points. floor() & ceil () I think do it too. Link to comment https://forums.phpfreaks.com/topic/145624-decimal-numbers/#findComment-764507 Share on other sites More sharing options...
allworknoplay Posted February 17, 2009 Share Posted February 17, 2009 hi i'm busy with a php practical and need help with decimal numbers. The worked out a sum and its answer displays 18.5953893. I need it show only 2 numbers after the break, like 18.60 Can anyone help me please?? $number = 18.5953893; $new_number = number_format($number); Link to comment https://forums.phpfreaks.com/topic/145624-decimal-numbers/#findComment-764509 Share on other sites More sharing options...
common Posted February 17, 2009 Author Share Posted February 17, 2009 thanks i used the round($number,2) and it works. thanks a lot Link to comment https://forums.phpfreaks.com/topic/145624-decimal-numbers/#findComment-764517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.