I've got a piece of code that runs through each element in an array doing stuff. It can take a while depending on the size of the array, so I figured I'd be nice and output some percentages to make sure the user knows that something is infact happening... so I stuck this in the loop. ($percent is initiated to 1)
[tt]
if($percent <= 10 && $cur == int($total/10*$percent)){
print " ".$percent."0\%";
$percent++;
}
$cur++;
[/tt]
Now this SHOULD output:
[tt] 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%[/tt]
and it works fine in any C program I've ever written,
but instead it doesn't output anything. HOWEVER, if I change the code to:
[tt]
if($percent <= 10 && $cur == int($total/10*$percent)){
print " ".$percent."0\%\n";
$percent++;
}
$cur++;
[/tt]
(added /n)
it works fine, outputting
[tt]
10%
20%
30%
...
100%
[/tt]
So it only works if I stick a \n in there... why would this be? any way around this? thanks
[tt]
if($percent <= 10 && $cur == int($total/10*$percent)){
print " ".$percent."0\%";
$percent++;
}
$cur++;
[/tt]
Now this SHOULD output:
[tt] 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%[/tt]
and it works fine in any C program I've ever written,
but instead it doesn't output anything. HOWEVER, if I change the code to:
[tt]
if($percent <= 10 && $cur == int($total/10*$percent)){
print " ".$percent."0\%\n";
$percent++;
}
$cur++;
[/tt]
(added /n)
it works fine, outputting
[tt]
10%
20%
30%
...
100%
[/tt]
So it only works if I stick a \n in there... why would this be? any way around this? thanks