Tom Worster wrote: > there's a control structure i wish php had: a simple block that you can > break out of, e.g. > > block { > > if ( condition ) > break; > > blah... > blah... > > if ( another condition ) > break; > > blah... > blah... > > etc... > > } > > the block is just like a loop except that it is executed once only. > > this would be a handy structure for writing input validation code. the blah > blah fragments can be used for opening files, talking to the db, > manipulating strings, processing dates and times, etc., the conditions for > testing if the input is unacceptable. > > i'm sure many of the programmers here do this kind of thing routinely and > have their own habits and solutions. i'd be curious what they are. please > let us know! > > > i guess i ought to go first. it's fugly but it works: > > $once = true; > while ( $once ) { > $once = false; > > stuff using break where needed ... > > } > > tom > > >From the PHP manual: do { if ($i < 5) { echo "i is not big enough"; break; } $i *= $factor; if ($i < $minimum_limit) { break; } echo "i is ok"; /* process i */ } while (0); -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php