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?

Recommended Answers

All 3 Replies

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

can you help me build a c++break code and flowchart?

tnx..Rachelle

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;
	
}

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.