diff --git a/language/control-structures.xml b/language/control-structures.xml index eac86c12a0..6498b47a87 100644 --- a/language/control-structures.xml +++ b/language/control-structures.xml @@ -91,11 +91,14 @@ if ($a > $b) { } + The else statement is only executed if the if expression evaluated to FALSE, and if there were any elseif expressions - only if they evaluated to - FALSE as well (see below). + FALSE as well (see elseif). + @@ -534,28 +537,28 @@ foreach($a as $k => $v) { break ends execution of the current - if, for, - while, or switch - structure. + for, while, or + switch structure. + break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of. + -$i = 0; -while ($i < 10) { - if ($arr[$i] == "stop") { - break; /* You could also write 'break 1;' here. */ - } - $i++; +$arr = array( 'one', 'two', 'three', 'four', 'stop', 'five' ); +while ( list( , $val ) = each( $arr ) ) { + if ( $val == 'stop' ) { + break; /* You could also write 'break 1;' here. */ + } + echo "$val<br>\n"; } /* Using the optional argument. */ - $i = 0; while ( ++$i ) { switch ( $i ) {