Jump to content

Check percentage intervals


MuseiKaze

Recommended Posts

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

Link to comment
Share on other sites

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%";

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.