NYCPHP Meetup

NYPHP.org

[nycphp-talk] Conditional break?

Andy Dirnberger dirn at dirnonline.com
Fri May 4 21:11:35 EDT 2007


Try continue instead of break.

Sent via BlackBerry from Cingular Wireless  

-----Original Message-----
From: David Krings <ramons at gmx.net>
Date: Fri, 04 May 2007 21:01:29 
To:NYPHP Talk <talk at lists.nyphp.org>
Subject: [nycphp-talk] Conditional break?

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
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php



More information about the talk mailing list