MuseiKaze Posted March 2, 2010 Share Posted March 2, 2010 Hiya, im having a bit of trouble finding a solution to a problem im having. I have a program ive written and it prints out a percentage everytime it checks an item, but I need to reduce the amount of times it prints to the page because its causing some lag due to the number of items. Im using this to find the percentage completed $getpercent = (100 / $total) * $i; $percent = round($getpercent, 2); Is there any way I can use a statement to find out if the percentage is at an interval of say 5. So it would only print out at 5%,10%,15% etc.. Hope that makes sense. Thanks heaps Quote Link to comment Share on other sites More sharing options...
MuseiKaze Posted March 2, 2010 Author Share Posted March 2, 2010 After a bit of messing around I found a solution that lets me check every 1% by rounding down the percent to 0 decimal places and storing $percent in $interval if percent isnt equal to interval. Seems to work fine. Would still be interested to know if theres a function or other method that can use to do this though. $getpercent = (100 / $total) * $i; $percent = round($getpercent, 0); if ($percent != $interval) { $interval = $percent; print "$percent%"; } 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.