Dysan Posted February 25, 2008 Share Posted February 25, 2008 Hi, With reference to decimal numbers, how do I keep only the first 2 numbers after the decimal point? <?php $number = 5.5; echo $number / 3; ?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted February 25, 2008 Share Posted February 25, 2008 check number_format function Quote Link to comment Share on other sites More sharing options...
Dysan Posted February 25, 2008 Author Share Posted February 25, 2008 Is it possible to just cut the numbers off after the 2 numbers following the decimal place? Quote Link to comment Share on other sites More sharing options...
mainewoods Posted February 25, 2008 Share Posted February 25, 2008 if you want to just truncate after the 2 decimals, do this: $truncatednumber = floor($startnumber * 100) / 100; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.