PHP Array Previous Function

What is prev() Function?

Explanation

The "prev()" function can get the internal pointer to the previous array element

Syntax:


prev(array)

In the above syntax "array" is the array in which the pointer is to be rewinded.

Example :


<?php
$b=array("Grapes","Apple","Cherry");
echo current($b)."<br/>";
echo next($b)."<br/>";
echo prev($b)."<br/>";
?>
Result :

Grapes.
Apple.
Grapes.

In the above example the array "$b" first the current value, then the next value and the previous values are displayed.

PHP Topics


Ask Questions

Ask Question