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: 30-Jul-2019

52 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements