PHP » Arrays » prev()

Syntax:
mixed prev(array array)
array
The array to get the previous element from.

Returns the previous element.

The prev() function moves the internal pointer of an array to the previous element and returns that element.

Examples

Code:
<?php

$array1 = array("one", "two", "three");

end($array1);
while ($element = current($array1)) {
   print "$element ";
   prev($array1);
}

?>
Output:
three two one
Explanation:

This example shows how the prev() function can be used to go through an array starting at the end.

See Also: