PHP prev() Function

The prev() function moves the internal pointer to, and outputs, the previous element in the array.

Returns the value of the previous element in the array on success, or FALSE if there are no more elements

The previous element of Cooper is Samuel

Parameter Description
array Required. Specifies the array to use

Syntax

prev(array) 

Example

$people = array("Cooper","Samuel","James","Alex");
echo current($people) . "<br>";
echo next($people) . "<br>";
echo prev($people);

Output

Cooper
Samuel
Cooper

Leave a Reply

Your email address will not be published. Required fields are marked *