Find one tenth of a variable and round up to the next whole number and find remainder
Ok, so I have an undetermined number of entries.. (user can add additional tasks to the list, each project has 1 of each task) I need to know how many are "10 percent" of the total so that I can divide them into 10 more-or-less equal parts.
Each entry has a "status", which will always be completed in order, and if they are complete then I want to be able to say that the total is 10% complete, 20% complete, etc... So if there are 10 of them and 4 are complete, then it would be 40 percent, but if there are 100 of them and 40, 41, 42, 43, 44, etc, to 49 are complete, then it would say 40 percent complete... but likewise if there are 15 tasks then if there are 7 done it would say 40% complete because 7/15=.466 a.k.a.. 47% complete.
Also, if you noticed, I don't want it to "round to the nearest 10 percent" I want it to be at or above a percentage when it's shown, so 49% is not 50% complete.
Any help would be greatly appreciated; thanks!
$percent = floor(($total / $count) * 10) * 10;
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)