+ 2

Can somebody explain me this code?

<?php $i=1; While($i<3){ Echo $i%2; $i++; } ?> The result is 10 but i have no idea why.. Thanks

11th Aug 2018, 9:16 PM
razvan
razvan - avatar
2 Answers
+ 5
i is 1 1 % 2 == 1 i is 2 2 % 2 == 0 i is 3 the loop stops so, 10 is printed
11th Aug 2018, 9:44 PM
hinanawi
hinanawi - avatar
+ 2
thank you for that..it was that easy..i am embarrassed now..
11th Aug 2018, 9:46 PM
razvan
razvan - avatar