View Single Post
Old 04-22-2008, 05:07 PM   #1 (permalink)
delayedinsanity
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default Breaking out of a... not a loop.

Is there any way, say if you were using curly braces to organize your code into blocks, ie;

PHP Code:
function somecall() {
$var "somevar";

    {
     if (
$then) { do(); }
     while (!
$crashed) { crash(); }
    }


can you break out of those blocks like you can break out of a loop? Dependent of course on something evaluating to true, say halfway through the block there's an if statement that checks a value and if it's true, I don't want to process the rest of the block.

This is for purely aesthetic reasons at this point, I'm trying to create a block of if statements that will look more like a switch statement than a spaghetti mess of if's and else if's.

PHP Code:
{
  if (empty(
$value)) { dothis(); break; }
  if (!
ctype_alpha($value)) { dothis(); break; }
  if (
strcasecmp($value$othervalue)) { dothis(); break; }

-m
delayedinsanity is offline  
Reply With Quote