0

Is there anything or keawords in PHP from which I can break or continue from a LOOP in PHP??

in C
for(i=0;i<=100;i++){
statement1....;
statement2....;

if(condition1)
break;
else
continue;
statement3....;
statement4....;
statement5....;
}

I need something like this in PHP..
Can anybody Help me?

4
Contributors
3
Replies
4
Views
12 Years
Discussion Span
Last Post by johnsquibb
0

In a loop, the break and continue keyworks work as in C; however, for IF I am not certain. Best to try them out and see what works, or check www.php.net

0

Is there anything or keawords in PHP from which I can break or continue from a LOOP in PHP??

in C
for(i=0;i<=100;i++){
statement1....;
statement2....;

if(condition1)
break;
else
continue;
statement3....;
statement4....;
statement5....;
}

I need something like this in PHP..
Can anybody Help me?

syntax is the same as c. for example:

<?php

for($i=0; $i < 50; $i++)
{
	//skip numbers 4
	if($i == 4)
	{
		continue;
	}
	
	//exit early
	if($i == 25)
	{
		break;
	}
	
	//print each result
	echo $i;
	
}

?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.