 |
|
ss
Oracle Tips by Burleson |
array range (
number low, number high [, number step] )
This range() returns an array of elements from
low to high, inclusive. If low > high, the sequence is
from high to low. The optional step parameter has been added in
PHP 5.0.0. If a step value is given, it is used as the
increment between elements in the sequence. step should be
given as a positive number. If not specified, step defaults to
1. This function is extremely useful in looping through arrays with
the foreach statement.
The following example shows how to do this:
#!/usr/local/bin/php
<?php
$sum=0;
$A=range(0,10);
foreach(range(0,10) as $i) {
$sum += $A[$i];
}
print("SUM=$sum\n");
?>
In this example the range function is used both to
define the array $A and to loop through it to compute the sum.
See
code depot for complete scripts
The above book excerpt is from:
Easy Oracle
PHP
Create Dynamic Web Pages with Oracle Data
ISBN
0-9761573-0-6
Mladen Gogala
http://www.rampant-books.com/book_2005_2_php_oracle.htm
|