Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

pos


You may use pos as an alias to the current function.


value prev(array arrayname)


The prev function operates similarly to the next function with the exception that it
moves backward through the array. The internal pointer to the array is moved back one
element, and the value at that position is returned. If the pointer is already at the
beginning, FALSE is returned.


<?
$colors = array("red", "green", "blue");
end($colors);
$my_color = current($colors);
do
{
print("$my_color
\n");
}
while($my_color = prev($colors))
?>


array range(integer start, integer stop)


Use range to create an array containing every integer between the first argument and the
second, inclusive.


<?
$numbers = range(13, 19);


//print out all the values
foreach($numbers as $value)
{
print("$value
\n");
}
?>


value reset(array arrayname)


Use the reset function to move an array's internal pointer to the first element. The
element in the first position is returned. Use end to set the pointer to the last element.


<?
//create test data
$colors = array("red", "green", "blue");

Free download pdf