PHP prev() Function

PHP prev() Function

The prev() function in PHP rewinds or moves back the internal array pointer one place backward and returns the prev array value.

It behaves like next() function, except that this function rewinds the internal array pointer one place backward instead of advancing it.

Syntax

prev ( array &$array )

Parameter

array(required)- This parameter represents the input array.

Return

This parameter returns the previous array value in the place that's pointed to by the internal array pointer, or FALSE if there are no more elements.

Example 1

 

Output

The previous pointer of the array is at mango

Example 2

 

Output

The pointer of the array is at 

Example 3

 

Output

The pointer of the array is at 'bike'
The pointer of the array is at 'car'
The pointer of the array is at 'bike'
The pointer of the array is at 'cycle'
The pointer of the array is at '' 

Example 4

 

Output

The pointer of the array is at