Re: 'break' command question

From: Date: Fri, 07 Jul 2000 14:00:03 +0000
Subject: Re: 'break' command question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5383@lists.php.net to get a copy of this message
On Fri, 7 Jul 2000, Chris Gray wrote: > Using 'break 2' produces this error --- > Fatal error: Cannot break/continue 2 levels in > /home/httpd/html/ggg/break.php on line 5 > > > Please forgive my ignorance if there is some arcane Unix explanation for > this. > Or have I totally misunderstood the example? break; will take you out of the top level control structure, and it seems that if() statements are not classed as control structures under PHP. When you do a break <number>; you are breaking out of the top level control structure and trying to execute a second break; when there is no loop to break out of. What I usually do is if I am iterating until I find something useful, I put that in a control structure of it's own and allow the flow of the program to take me down to the next set of if() or while() clauses. I tried to write a mad regexp script with tons of nested loops and I ended up getting lost. ;) I hope that makes sense. Cheers, Nicky W.. -[ pioneer@dac.org ]- "Mibbies naw tha'day, mibbies maw tha'morra, but soon... fer the rest o' yer nelly puff!"

« previous php.general (#5383) next »