TheFilmGod Posted March 19, 2007 Share Posted March 19, 2007 how do I do integer divide in php. E.G. 10 / 3 = 3 not 3.333333 Quote Link to comment https://forums.phpfreaks.com/topic/43386-solved-php-divide/ Share on other sites More sharing options...
wildteen88 Posted March 19, 2007 Share Posted March 19, 2007 If you want to get whole numbers and not decimal numbers use ceil (for rounding up) or floor (rounding down). Eg: $sum = 10 / 3; echo floor($sum); // result: 3 Quote Link to comment https://forums.phpfreaks.com/topic/43386-solved-php-divide/#findComment-210702 Share on other sites More sharing options...
TheFilmGod Posted March 19, 2007 Author Share Posted March 19, 2007 Can you give me an example? Like 10 / 3 (round up) Quote Link to comment https://forums.phpfreaks.com/topic/43386-solved-php-divide/#findComment-210704 Share on other sites More sharing options...
wildteen88 Posted March 19, 2007 Share Posted March 19, 2007 I forgot to add an example in my post earlier. Re-check my post. It has an example now. If you want to round up change floor to ceil instead. Quote Link to comment https://forums.phpfreaks.com/topic/43386-solved-php-divide/#findComment-210706 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.