I am trying to build up a script that gets the current percentage of the iteration of a loop.
I have :
To calculate percentage, you take the current and divide it by the total, then multiply that value by 100, then round it off. I also take the floor value so that 99.7% doesn't round up to 100 since it's not truly complete yet.
for($i=1;$i<=count($yourArray);$i++) {
$percentage = floor(round( (($i / total) * 100), 1 ));
}