Have i created an infinite loop in this short PHP code? Browser just locks up

The goal is to count to 1000 by 50, and to skip 550 while numbers are being echoed to browser.  What am i doing wrong?  Thanks!

<?php

$distance = 50;

while ($distance < 1000) {
	echo $distance . "<br>";
	if ($distance == 550) {
		continue;
	}
	$distance += 50;
	} 
	?>

Open in new window

LVL 1
LB1234Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
The way you wrote it, $distance doesn't change when you get to 550.  This is what I would do.
<?php

$distance = 0;

while ($distance < 1000) {
	$distance += 50;
	if ($distance == 550) {
		continue;
	}
	echo $distance . "<br>";
	} 
	?>
                                  

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
COBOLdinosaurCommented:
continue skips to the end of the loop so once you hit 550 there is no further increment.
Try:

<?php

$distance = 50;

while ($distance < 1000) {
	echo $distance . "<br>";
	if ($distance != 550) $distance += 50;
	} 
	?>

Open in new window


Cd&
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.