PHP prev() Function

PHP prev Function


Definition :

In PHP Array funciton PHP prev is an inbuilt function in PHP. prev() function is used to  moves the internal pointer to, and outputs, the previous element in the array.

Related methods:

  • next() - moves the internal pointer to, and outputs, the next element in the array
  • current() - returns the value of the current element in an array
  • end() - moves the internal pointer to, and outputs, the last element in the array
  • reset() - moves the internal pointer to the first element of the array
  • each() - returns the current element key and value, and moves the internal pointer forward
  Syntax

    prev(array)

Parameter Values
Parameter Description
array Required. Specifies the array to use

 

Example1 : In this given below example Output the value of the current, next and previous element in the array:

:

 Ouput : 

Web
Desinging
Web

Example2 : A demonstration of all related methods

Output : 

Apple
Mango
Mango
Apple
Banana
Apple