pfkdesign Posted September 3, 2008 Share Posted September 3, 2008 hi everybody. i have problem with rounding and i wounder if you can help me. i want to round numbers which rounded down if it is less than *5, and round up if greater than *5 ex. if there are between 10-14 shows 10, 15-19 shows 20 14 -> 15 12 -> 10 9 -> 10... $current= date('Y'); $yeasexperience= $row_rsexperience['years_ex']; $total= $current - $yeasexperience; echo round($total); echo " years of experience"; any idea? Quote Link to comment https://forums.phpfreaks.com/topic/122515-solved-rounded-numbers/ Share on other sites More sharing options...
alin19 Posted September 3, 2008 Share Posted September 3, 2008 $number=15; $number=$number/10; $number=round($number); $number=10*$number; Quote Link to comment https://forums.phpfreaks.com/topic/122515-solved-rounded-numbers/#findComment-632568 Share on other sites More sharing options...
pfkdesign Posted September 3, 2008 Author Share Posted September 3, 2008 thank you, it was perfect. Quote Link to comment https://forums.phpfreaks.com/topic/122515-solved-rounded-numbers/#findComment-632576 Share on other sites More sharing options...
Mchl Posted September 3, 2008 Share Posted September 3, 2008 Or just $number=round($number,-1); Quote Link to comment https://forums.phpfreaks.com/topic/122515-solved-rounded-numbers/#findComment-632586 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.