Prev () Definition and usage
The prev () function moves the pointer to the current element to the position of the previous element and returns the element value.
If the internal pointer already exceeds the first element of the array, the function returns FALSE.
Grammar
Prev (array) parameter description
Array required. Specify the array to use.
Description
The behavior of Prev () and Next () is similar, but it pours the internal pointer back one rather than forward.
Note: If the array contains empty cells, or if the cell value 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
Copy Code code as follows:
<?php
$people = Array ("Peter", "Joe", "Glenn", "Cleveland");
Echo current ($people). "<br/>";
Echo Next ($people). "<br/>";
Echo prev ($people);
?>
Output:
Peter
Joe
Peter