Reset (PHP 3, PHP 4, PHP 5)
Reset--point the inner pointer of the array to the first cell
Description
Mixed reset (array &array)
Reset () returns the internal pointer of the array back to the first cell and returns the value of the first array cell, FALSE if the array is empty.
Example 1. Reset () example
Copy the Code code as follows:
$array = Array (' Stepone ', ' Step ', ' step three ', ' step Four ');
By default, the pointer are on the first element
Echo current ($array). "
\ n "; "Stepone"
Skip Twosteps
Next ($array);
Next ($array);
Echo current ($array). "
\ n "; "Stepthree"
Reset pointer, start again on step one
Reset ($array);
Echo current ($array). "
\ n "; "Stepone"
?>
Next (PHP 3, PHP 4, PHP 5)
Next-Moves the inner pointer in the array forward one
Description
Mixed next (array &array)
Returns the value of the next cell pointed to by the array's internal pointer, or FALSE if there are no more cells.
Next () and current () behave similarly, with only a little difference, moving the inner pointer forward one bit before the return value. This means that it returns the value of the next array cell and moves the array pointer forward one bit. If the result of moving the pointer is beyond the end of the array cell, then next () returns FALSE.
Warning
If the array contains empty cells, or if the value of the cell is 0, the function encounters these cells and returns FALSE. To properly traverse an array that may contain empty cells or a cell value of 0, see the each () function.
Example 1. Example of use of next () and related functions
Copy the Code code as follows:
$transport = Array (' foot ', ' bike ', ' car ', ' plane ');
$mode = current ($transport); $mode = ' foot ';
$mode = Next ($transport); $mode = ' bike ';
$mode = Next ($transport); $mode = ' car ';
$mode = prev ($transport); $mode = ' bike ';
$mode = End ($transport); $mode = ' plane ';
?>
Current (PHP 3, PHP 4, PHP 5)
Current--Returns the cell in the array
Description
Mixed current (array &array)
Each array has an internal pointer to its "current" cell, which initially points to the first cell inserted into the array.
The current () function returns the value of the array cell that is currently pointed to by the internal pointer and does not move the pointer. If the internal pointer points beyond the end of the cell list, current () returns FALSE.
Warning
If the array contains empty cells (0 or "", an empty string), the function returns FALSE when it encounters this unit. This makes it impossible to use current () to determine whether the end of this array list is reached. To properly traverse an array that may contain empty cells, use the each () function.
Example 1. Examples of usage of current () and related functions
Copy the Code code as follows:
$transport = Array (' foot ', ' bike ', ' car ', ' plane ');
$mode = current ($transport); $mode = ' foot ';
$mode = Next ($transport); $mode = ' bike ';
$mode = current ($transport); $mode = ' bike ';
$mode = prev ($transport); $mode = ' foot ';
$mode = End ($transport); $mode = ' plane ';
$mode = current ($transport); $mode = ' plane ';
?>
http://www.bkjia.com/PHPjc/328073.html www.bkjia.com true http://www.bkjia.com/PHPjc/328073.html techarticle Reset (PHP 3, PHP 4, PHP 5) Reset--Points the inner pointer of the array to the first unit description mixed reset (array lt; PHP $array = Array (' Stepone ', ' Step ', ' Step three ', ' step four ...