prev() function in PHP



The prev() function rewinds the internal array pointer. It outputs the previous element in the array.

Syntax

prev(arr)

Parameters

  • arr − The specified array. Required.

Return

The pos() function returns the value of the previous element in an array.

Example

The following is an example −

Live Demo

<?php
   $arr = array("one", "two");
   echo pos($arr);
   echo next($arr);
   echo prev($arr);
?>

Output

one
two
one
Updated on: 2019-07-30T22:30:23+05:30

105 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements