Link to home
Start Free TrialLog in
Avatar of LB1234
LB1234

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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&