+ 16
why output 1 3 5 7 9 ???
someone can explain???whyyyy for ($i=0;$i<10;$i++){ if($i%2==0){ continue; } echo $i.' '; } //output 1 3 5 7 9
2 Respostas
+ 9
Hey, what I believe is happening, is that the continue is causing the remainder of the body of the for loop to be skipped, so instead of printing the number out, it is going straight to incrementing the value of $i.
Thus all the even numbers are skipped due to the remainder being 0
+ 1
it simply says if i is equals to zero
I is less than 10 so increment I
if I modulo 2_ is equal to zero .."only even numbers " continue
that means all odd numbers will be the output