|
 |
|
Oracle Tips by Burleson
|
Loop
Control Statements
PHP recognizes two loop control statements,
break and continue. The break statement exits from
the loop immediately, while the continue statement terminates
the current loop iteration and continues with the next. Syntax for
both statements is extremely simple as shown below:
Despite being extremely simple, these two
statements are also extremely useful. The following is an example
illustrating both statements:
#!/usr/local/bin/php
<?php
$N=array(1,2,3,4,5,"next",6,7,8,9,"stop",10);
foreach ($N as $n) {
if ($n=="next") { continue; }
if ($n=="stop") { break; }
print "$n ";
}
print "\n";
?>
When executed, this script displays the
following:
$
./example7.php
1 2 3 4 5 6 7 8 9
The words “next” and “stop” or the number 10 are
not printed. When the loop encounters the word “next”, it executes the
continue command which skips the rest of the loop and continues
with the next iteration. When the word “stop” is discovered, the
break command terminates the loop immediately.
See
code depot for complete scripts
This is an excerpt from the book
Easy Oracle PHP. You can get it
for more than 30% by buying it directly from the publisher and get
instant HTML-DB scripts from the code depot:
 |
Easy Oracle PHP
Create Dynamic Web Pages with Oracle Data
Includes online HTML-DB code depot
Buy it now for 30% off
- Only $19.95
|
HTML-DB support:
 |
For HTML-DB development support just call to gat an
Oracle Certified professional for all HTML-DB development
projects. |
|