...

View Full Version : while ==



paperino00
04-16-2012, 07:22 PM
Hello, why in a while cicle I can't use the equal operator? This code for example doesn't work


<?php
$i = 0;
do {
echo $i;
$i++;
} while ($i == 10);
?>

but if I use <= it works


<?php
$i = 0;
do {
echo $i;
$i++;
} while ($i <= 10);
?>

Thank you!

chunky
04-16-2012, 07:29 PM
Think about it, i starts at 0 but ONLY goes up by 1 if that code is run, but that code only runs while i is 10, but it will never be 10 because that code is never run.......... Think about it :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum