NYCPHP Meetup

NYPHP.org

[nycphp-talk] Conditional break?

David Krings ramons at gmx.net
Fri May 4 21:01:29 EDT 2007


Hi!

Try to make this short. I have an array with path/file names. I want to 
move each file unless it already exists at its destination. What I want 
to do is end the current go through the while loop, increase a counter 
that I use for the while condition, and then start at the top of the 
while loop again. I tried using break as such

while ($counter < $max) {
	$error = move_file();
	if (!$error) {
		echo "Failed!"
		$counter++;
		break;
	} else {
		do_some_stuff();
	}
	$counter++;
}

The problem is that the whole thing stops as soon as it hits break, but 
I just want it to stop what it is doing now, increase $counter, and go 
back to the top and loop again. Obviously, break isn't the right thing 
to use. But what is?

Hope this is a more intelligent question than the others I asked in the 
past days. Sorry for that.

David



More information about the talk mailing list